Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Window.onbeforeunload not being fired for browser back  RSS feed

jishnu dasgupta
Ranch Hand
Posts: 103
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp page,home.jsp, which consist of two frames: Header and Content
The Header section is always constant and the Content keeps on changing.
In some of the jsps which are displayed in the Content Frame, I have link tag as:

where downloadAttachment is a javscript function which has the below call:

where RetirevFile.display is a servlet which reads a document from a shared location and then writes it to the outpust stream,which allows me to save,open or cancel the document download.

Now in my home.jsp, I have a check for onbeforeunload like


Ideally, the above onbeforeunload event would be triggered when home.jsp is unloaded. I have also ensured that whatever jsp is being displayed in the content frame is not being saved in browser cache.

Now , suppose i am in google, and then go to home.jsp and navigate to a page which has an attachment.When i click on the download atttachment link, the attachment is downloaded corectly, adn i get the option to open,save or cancel the download. Once i have clicked any of them, and the click the browser back button, then i get the popup message from home.jsp.
But, if i perfom any other action on the jsp after that(like submitting or closing a form) and then click browser back, i do not get any pop up message and am redirected taken to google.
Could you please tell me, why i am not getting the pop up, even though home.jsp is getting unloaded. i am using ie8 for my application
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!