IHTMLWindow2 onunload event not triggered consistently
Working in C#:
In IE's document complete event handler
(DWebBrowserEvents2_DocumentCompleteEventHandler), using the web
browser object Document member as HTMLDocument and using the
parentWindow member as IHTMLWindow2 and HTMLWindowEvents2_Event, I add
an event handler in the form of an anonymous delegate to the onunload
member of HTMLWindowEvents2_Event.
I find that in most pages, the onunload event triggers as expected.
However, in other pages, like cnn.com, I find that a number of frames
do not ever trigger the onunload event. Looking through the source of
one of the frames, I come across this:
=============================================================
http://i.cdn.turner.com/cnn/.element/js/2.0/csi_include.js
var oldonloadfunction = window.onunload;
function dummyonunload(evt)
{
if(oldonloadfunction)
{
oldonloadfunction(evt);
}
}
window.onunload=dummyonunload;
=============================================================
I haven't traced through all the frames that are loaded to see when
this is invoked, but I wonder if it's possible that a statement like
this would somehow "detach" the delegate that's supposed to handle the
window.onunload event.
Whether or not that is the case, is there a way to make sure the
onunload event fires when it's supposed to?
Thanks.
date: Wed, 2 Jul 2008 12:20:03 -0700 (PDT)
author: unknown