A createPopup shown during the onunload event persists after the user navigates away. The popup stays visible on screen even though the page that created it is gone. It’s a minor issue but shouldn’t be possible — unload should clean up all UI associated with the page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>createPopupShowOnUnload</title></head>
<body>
<font size="2" face="Tahoma">
<center>
This little Script will show a createPopup() after the user leaves the page... <br /><br />
No big deal, but it should be killed as soon as the user changes the URL.
Let's go to <a href="http://www.google.com">Google</a> and see...
</center>
<hr />
onunload = function()<br />
{<br />
opener = createPopup();<br />
opener.show(0,0,200,200);<br />
opener.document.bgColor = "blue";<br />
}<br />
<hr />
<script>
onunload = function()
{
opener = createPopup();
opener.show(0,0,200,200);
opener.document.bgColor = "blue";
}
</script>
</font>
</body>
</html>
Storing the popup reference in opener during onunload prevents it from being destroyed with the page. The popup window has no obvious connection to any page once the original document is gone, so IE left it open. A page transitioning to a different origin could use this to leave a floating, styled overlay on screen.
Found during my years at Microsoft (2006–2014). These bugs were patched long ago — shared here as a historical record for learning purposes.
Read other posts