Forums Register Login

Javascript question about window.onbeforeunload

+Pie Number of slices to send: Send
I'm working on an application that uses Javascript. When the user attempts to close a Web page, there is a pop-up window that comes up with two buttons: Leave this page and Stay on this page. How would I know if the user clicked on the "Leave this page" button? How would I know what the user clicked when using window.onbeforeunload?
+Pie Number of slices to send: Send
Hi Fred

Sorry for the delay in answering - I wasn't sure what to say. The fact is that I don't work with windows much - even back in the day, when they were more popular, I generally avoided them. The book covers the basics of working with windows, but doesn't go in to a lot of detail, because there isn't much demand anymore. So, unfortunately, this all means that I don't know the answer to your question right off the top of my head. Are you having much luck when you Google it?

Fred Victa wrote:I'm working on an application that uses Javascript. When the user attempts to close a Web page, there is a pop-up window that comes up with two buttons: Leave this page and Stay on this page. How would I know if the user clicked on the "Leave this page" button? How would I know what the user clicked when using window.onbeforeunload?

 
+Pie Number of slices to send: Send
 

Mary Delamater wrote:Hi Fred

Sorry for the delay in answering - I wasn't sure what to say. The fact is that I don't work with windows much - even back in the day, when they were more popular, I generally avoided them. The book covers the basics of working with windows, but doesn't go in to a lot of detail, because there isn't much demand anymore. So, unfortunately, this all means that I don't know the answer to your question right off the top of my head. Are you having much luck when you Google it?

Fred Victa wrote:I'm working on an application that uses Javascript. When the user attempts to close a Web page, there is a pop-up window that comes up with two buttons: Leave this page and Stay on this page. How would I know if the user clicked on the "Leave this page" button? How would I know what the user clicked when using window.onbeforeunload?



I found this site helpful:

https://www.sitepoint.com/community/t/window-onbeforeunload-know-what-the-user-clicked/2568/5
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 660 times.
Similar Threads
Has anybody forund an answer-Browser window closing
A question about closing a shell in SWT
Javascript Guru Needed
Reloading a parent window 1 after submit from window 2
close pop up window from servlet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:19:57.