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() {
a = 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);
b = 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);
c = 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==h || 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>