Fossi in te cambierei completamente approccio...
codice:<!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Esempio</title> <script type="text/javascript"> var bShown = false; function docClick (oPssEvt) { var bChange = bShown, oEvt = oPssEvt || /* IE */ window.event; for (var oEl = oEvt.target; oEl; oEl = oEl.parentNode) { if (oEl.className === "finestrella") { bChange = false; } else if (oEl.id === "pulsante") { bChange = true; break; } } if (bChange) { for (var nIdx = 0, aEls = document.getElementsByClassName("finestrella"); nIdx < aEls.length; nIdx++) { aEls[nIdx].style.display = bShown ? "none" : "block"; } bShown = !bShown; } } document.onclick = docClick; </script> <style type="text/css"> .finestrella { position: fixed; display: none; left: 0; top: 0; width: auto; height: auto; } #myDiv { width: 300px; height: 200px; left: 200px; top: 200px; background-color: #00ff00; } </style> </head> <body> <div class="finestrella" id="myDiv"> Hello world!</p></div> <div class="finestrella" style="background-color:#aaaaaa;">Another hello world!</div> <div id="pulsante">Clicca qui</div> </body> </html>![]()

Rispondi quotando