Capturing the object that fires the OnBeforeUnload event of the window 
Author Message
 Capturing the object that fires the OnBeforeUnload event of the window

Hi!!  I hope everybody is doing ok. I'm developing an application and I need
that the user select the Logoff option from my Main Menu before leave the
application, so I'm trying to send a message when the OnBeforeUnload eventof
the window fires, letting the user now that the procedure to follow is
select the Logoff option from the Main Menu.  My Problem is that this event
fires not only when that user select the close button of the browser or
enter a new URL, it fires even when the user is navigating in my application
an is requesting a new page.  So I was trying to capture the object that
fires the OnBeforeUnload event with the window.event.srcelement, but I haven
't made it work in the way I want.  If someone has an example of this, or
know where can I look for it, please let me know.

  Thanks in advance for any help.

Marlene Arauz Martin
WDS



Wed, 25 Aug 2004 22:33:11 GMT  
 Capturing the object that fires the OnBeforeUnload event of the window

| select the Logoff option from the Main Menu.  My Problem is that this
| event fires not only when that user select the close button of the browser
| or enter a new URL, it fires even when the user is navigating in my
| application an is requesting a new page.

One word: Frames.

But you'll need to ensure that links to external pages will be targeted to
"_top", not to "_self".

:: "Ekevu Guepardo" ::
:: Acinonyx jubatus ::
:: Porto Alegre, BR ::



Wed, 25 Aug 2004 23:54:04 GMT  
 Capturing the object that fires the OnBeforeUnload event of the window
You could try setting a flag whenever the user clicks on an internal link,
then checking the value of the flag in your unload function.  If it's set,
then just exit the function without any action.

<SCRIPT LANGUAGE="JavaScript">
<!--
var gFlag=0;

function chkUnload(){
if(gFlag==0)alert("Please use....");

Quote:
}

//-->
</SCRIPT>

<A href="nextpage.asp" onclick="gUnload=1;">Next Page</a>

Tim.



Quote:
> Hi!!  I hope everybody is doing ok. I'm developing an application and I
need
> that the user select the Logoff option from my Main Menu before leave the
> application, so I'm trying to send a message when the OnBeforeUnload
eventof
> the window fires, letting the user now that the procedure to follow is
> select the Logoff option from the Main Menu.  My Problem is that this
event
> fires not only when that user select the close button of the browser or
> enter a new URL, it fires even when the user is navigating in my
application
> an is requesting a new page.  So I was trying to capture the object that
> fires the OnBeforeUnload event with the window.event.srcelement, but I
haven
> 't made it work in the way I want.  If someone has an example of this, or
> know where can I look for it, please let me know.

>   Thanks in advance for any help.

> Marlene Arauz Martin
> WDS



Thu, 26 Aug 2004 02:46:53 GMT  
 Capturing the object that fires the OnBeforeUnload event of the window
Can you be more explicit???? What is that I need to do with the frames??

Thank U!!

Marlene A.



Thu, 26 Aug 2004 03:30:12 GMT  
 Capturing the object that fires the OnBeforeUnload event of the window

| Can you be more explicit???? What is that I need to do with the frames??

All you need to do is create a parent frameset and a child frame. As the
user navigates on your application, in the child frame, there's no
onbeforeunload event at all. But the parent frameset DOES have a
onbeforeunload event. When there is a link to an external page, it will be
<a target=_top href=whatever>, which means the parent frameset will have its
onbeforeunload event fired.

And, when the user clicks on your logoff link, you will erase the
onbeforeunload event for the parent frame.

window.parent.onbeforeunload = null;

:: "Ekevu Guepardo" ::
:: Acinonyx jubatus ::
:: Porto Alegre, BR ::



Thu, 26 Aug 2004 07:18:21 GMT  
 Capturing the object that fires the OnBeforeUnload event of the window
I got it!!  Thank very much!!

Marlene A. Roman



Thu, 26 Aug 2004 20:22:41 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. onbeforeunload Event not fired when written trough xsl and frameset (no kidding)

2. onBeforeUnload fired by window.open??

3. Determining which object fired event from event handler.

4. Firing events on a parent IE window from a child IE window

5. handling the "onbeforeunload" window event

6. onbeforeunload event of window

7. IE BUG?: BODY's OnBeforeUnload fires twice for <A href that causes postback

8. Object in ASP page not firing events

9. Cloned tbody object refuses to fire onclick event (addendum to previous post)

10. Handling events fired from an ATL COM object in VBScript

11. window onresize event firing

12. Windows onload event some times not fired

 

 
Powered by phpBB® Forum Software