Hi all ,
I was just going through the onneforeunload property here:
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 :
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
I was just going through the onneforeunload property here:
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 :
Code:
var needToConfirm = true;
window.onbeforeunload = confirmExit;
function confirmExit()
{
// Handle what to do
}
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
Comment