Visualizzazione dei risultati da 1 a 2 su 2

Discussione: onmouseout e div

  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2009
    Messaggi
    57

    onmouseout e div

    Ciao, ho un problema a usare l'evento onmouseout:
    se passo col mouse sull'immagine più piccola, il div si chiude, mentre se rimango sull'immagine grande, il div rimane aperto, se tutte e due le immagini sono contenute nel div perchè se passo sulla seconda si chiude??
    Codice PHP:
    <html>
    <
    body>

    <
    script type="text/javascript">

    document.createElement("div");
    a.setAttribute("id""map");
    a.setAttribute("onmouseout""document.body.removeChild(a);"); 
    document.body.appendChild(a);

    document.createElement("img");
    b.setAttribute("src""http://img254.imageshack.us/img254/4802/immagineesempiolf5.jpg");
    b.setAttribute("width""200");
    b.setAttribute("height""200");
     
    document.getElementById("map").appendChild(b);

    document.createElement("img");
    c.setAttribute("src""http://www.calshop.biz/diario/wp-content/uploads/2006/03/Unaltra%20immagine%20della%20procace%20testimonial.%20Suo%20nonno%20si%20chiama%20George%20Bush,%20ma%20nessuna%20parentela%20la%20lega%20con%20il%20presidente.jpg");
    c.setAttribute("width""30");
    c.setAttribute("height""50");
    c.style.position="absolute";
    c.style.left="20%"
    document.getElementById("map").appendChild(c);
    </script>

    <input type="button" value="button" onclick="document.body.removeChild(a);" />

    </body>
    </html> 

  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 2009
    Messaggi
    57
    se faccio così funziona(su firefox) in pratica se l'id del parentNode del relatedTarget è diverso dall'id del target, allora chiudi, per le definizioni e spiegazioni QUI
    su internet explorer non funziona, a parte assegnare l'evento così:
    Codice PHP:
    a.onmouseout = function() {delCreate(event);}; 
    ma non posso assegnare l' eventPhase
    Codice PHP:
    <html id="html">
    <
    head id="testa">
    <
    script type="text/javascript">
    function 
    create() {
    document.createElement("div");
    a.style.height="300px";
    a.style.width="300px";
    a.style.border="2px solid black";
    a.setAttribute("id""map");
    a.innerHTML="ciao mondo";
    a.setAttribute("onmouseout""delCreate(event);"); 
    document.body.appendChild(a);

    document.createElement("img");
    b.setAttribute("src""http://www.derapate.it/wp-galleryo/paddock-girl-francia/paddock-girl-francia1.jpg");
    b.setAttribute("width""50");
    b.setAttribute("height""90");
    document.getElementById("map").appendChild(b);

    document.createElement("img");
    c.setAttribute("src""http://www.calshop.biz/diario/wp-content/uploads/2006/03/Unaltra%20immagine%20della%20procace%20testimonial.%20Suo%20nonno%20si%20chiama%20George%20Bush,%20ma%20nessuna%20parentela%20la%20lega%20con%20il%20presidente.jpg");
    c.setAttribute("width""30");
    c.setAttribute("height""50");
    c.setAttribute("id""girl");
    c.style.position="absolute";
    c.style.left="20%"
    c.style.display="list-item";
    document.getElementById("map").appendChild(c);
    }

    //se l'elemento ha come parentNode(genitore) un elemento con id diverso da quello prestabilito, //allora chiudi
    function delCreate(e) {
    b=e.target.id;
    h=e.relatedTarget.parentNode.id;

    if(
    b==|| e.eventPhase==3) {
    event.stopPropagation();
    }
    document.body.removeChild(a);
    }

    </script>
    </head>
    <body id="bod">
    <input type="button" value="button" onclick="create();" />
    <div style="width: 200px; height: 200px; border: 2px solid black; position: absolute; left: 45%;" id="dog">
    [img]http://i17.photobucket.com/albums/b62/Dhunter2010/Mortal%20Kombat/mortal-kombat-deadly-alliance-scorp.jpg[/img]
    </div>
    </body>
    </html> 

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.