aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Window.onbeforeunload not being fired for browser back Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Window.onbeforeunload not being fired for browser back" Watch "Window.onbeforeunload not being fired for browser back" New topic
Author

Window.onbeforeunload not being fired for browser back

jishnu dasgupta
Ranch Hand

Joined: Mar 11, 2011
Posts: 103

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


If debugging is the process of removing bugs, then programming must be the process of putting them in. -- Edsger Dijkstra

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Window.onbeforeunload not being fired for browser back