• Post Reply Bookmark Topic Watch Topic
  • New Topic

Javascript question about window.onbeforeunload  RSS feed

 
Fred Victa
Ranch Hand
Posts: 201
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mary Delamater
Author
Greenhorn
Posts: 23
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Fred Victa
Ranch Hand
Posts: 201
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!