Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > onbeforeunload : differentiate between different events

Reply
Thread Tools

onbeforeunload : differentiate between different events

 
 
rhitam
Guest
Posts: n/a
 
      05-13-2009
Hi all ,

I was just going through the onneforeunload property here:

http://www.4guysfromrolla.com/demos/...nloadDemo1.htm


Now , consider a scenario such as this :

my website is located at say www.mywebsite.com which has several web
pages for which i want to have the onneforeunload event . Now , assume
that all the web pages are including a js file where i can have the
code for the event which is like this :


var needToConfirm = true;
window.onbeforeunload = confirmExit;
function confirmExit()
{
// Handle what to do
}

now , the event can fire in either of the following cases:
1) Tab is closed
2) User navigates to another page within the same websote.
3) window is closed
4) User navigates to another page outside the domain of www.mywebsite.com


How to handle all these cases separately? To be more specific , how
can i tell whether the user has navigated within or outside the domain
of the website?

Any help appreciated.

Regards,
Rhitam


 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      05-13-2009
On May 13, 8:02*am, rhitam <(E-Mail Removed)> wrote:
> Hi all ,
>
> I was just going through the onneforeunload property here:
>
> http://www.4guysfromrolla.com/demos/...nloadDemo1.htm
>
> Now , consider a scenario such as this :
>
> my website is located at saywww.mywebsite.comwhich has several web
> pages for which i want to have the onneforeunload event . Now , assume
> that all the web pages are including a js file where i can have the
> code for the event which is like this :
>
> var needToConfirm = true;
> window.onbeforeunload = confirmExit;
> * function confirmExit()
> * {
> *// Handle what to do
> * }
>
> now , the event can fire in either of the following cases:
> 1) Tab is closed
> 2) User navigates to another page within the same websote.
> 3) window is closed
> 4) User navigates to another page outside the domain ofwww.mywebsite.com
>
> How to handle all these cases separately? To be more specific , how
> can i tell whether the user has navigated within or outside the domain
> of the website?
>
> Any help appreciated.


You can't do it.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Differentiate between user caused events and script generated events jmpinchot@gmail.com Javascript 1 04-27-2007 03:05 AM
Differentiate between static and dynamic allocated objects Jo C++ 7 12-28-2006 11:19 AM
How to differentiate between click event of multiple server buttons mayur_hirpara@hotmail.com ASP .Net 5 06-06-2006 03:42 PM
A Plea: Differentiate between Lens Chromatic Aberration and Sensor Chromatic Abbertion digiboy Digital Photography 3 12-06-2004 07:25 AM
How to differentiate between <XX></XX> and <XX/> with SAX dpj5754@yahoo.fr XML 13 08-11-2004 12:02 AM



Advertisments