Calling get_srcElement on IHTMLEventObj puts NULL in the srcElement



Hi,

I've hooked into the onunload event of IHTMLWindowEvents2 which has the
IHTMLEventObj as an in param.
My goal is to retrieve the URL of that window that triggered my
onunload.
The following code results in event_source beung NULL, meaning the
srcElement of the HTMLEventObj is NULL.

HRESULT __stdcall onunload(/*IHTMLEventObj*/IDispatch* disp_evt)
{
if (disp_evt) {
CComQIPtr<IHTMLEventObj> event_obj(disp_evt);
if (event_obj) {
CComQIPtr<IHTMLElement> event_source;
HRESULT hr = event_obj->get_srcElement(&event_source);
.....
}
}
}

Why is that ?
How do I retrieve the URL from my onunload sink ?

.



Relevant Pages

  • Re: onunload
    ... >I am trying to capture when the user clicks the X button on the ie window. ... > have used the onunload for the window event, ... Also, be aware that if the form has validation and validation fails, you may ...
    (microsoft.public.dotnet.framework.aspnet)
  • Determin users intention when onunload fires
    ... I want to use onunload to capture user's action when he ... the close window button on the ... upper-right corner of the brower window, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Is there any kind of event Onclose in webpages instead OnUnload??
    ... Is there any kind of event Onclose in webpages instead OnUnload?? ... Because sometimes I really to make somethings only when the window is closed ...
    (microsoft.public.scripting.jscript)
  • Re: Calling get_srcElement on IHTMLEventObj puts NULL in the srcElement
    ... My goal is to retrieve the URL of that window that triggered my ... The following code results in event_source beung NULL, ... srcElement is not valid for onunload event. ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • onUnload, window.open, and browser buttons
    ... I want to open a window when a user leaves my site. ... To skip the window.open if the user hasn't left my site, I set a variable in my links and test for it in the onUnload function. ... My workaround is to set up an onLoad function that tries to close the window if it's open. ... But that, essentially, causes the browser to flash, even if the open is a 1x1 window positioned off-screen. ...
    (comp.lang.javascript)