Re: Calling get_srcElement on IHTMLEventObj puts NULL in the srcElement



Lady_A <alexandra.lev@xxxxxxxxx> wrote:
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.

Why is that ?

By design. For each event, MSDN documentation lists all the properties
of the 'event' object that are valid for this particular event.
srcElement is not valid for onunload event.

How do I retrieve the URL from my onunload sink ?

onunload event doesn't bubble. You already know which element it is
coming from - the very same element you attached your sink to in the
first place. Read URL from that element.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



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)
  • 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)