wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Overriding Browser refresh button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Overriding Browser refresh button" Watch "Overriding Browser refresh button" New topic
Author

Overriding Browser refresh button

Pradeep Chandrasekharan Nair
Ranch Hand

Joined: Apr 01, 2004
Posts: 48
Can any one tell me how to override browser refresh button. actually my need is to submit a form when the browser is refreshed using javascript.

Thanks in Advance

Pradeep
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
i feel that you should search google first before posting the question. is much faster for you.
anyways i searched for it and got one link.
enjoy

http://www.htmlgoodies.com/tutorials/getting_started/article.php/3479551#itself
[ February 10, 2006: Message edited by: Niki Nono ]

Life called,so here I am.<br />Cheers<br />Niki.:-)
Pradeep Chandrasekharan Nair
Ranch Hand

Joined: Apr 01, 2004
Posts: 48
Actually i was enquiring about overriding the browser refresh button. ie. when i click on the browser refresh button, i need to call a javascript function. is this possible?
Christian Gross
Author
Ranch Hand

Joined: Feb 20, 2006
Posts: 85
Just off the top of my head here... There are the body events preunload, or unload? I know for the State Navigation pattern I used those events to detect when a page was reloaded or URL changed.


Author of Ajax Patterns and Best Practices
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You can not detect a refresh button clicked. the onunload gets called fro refresh, links click, browser closing, etc so it is really not a good solution. So the answer is, you really can not do it.

Eric
Christian Gross
Author
Ranch Hand

Joined: Feb 20, 2006
Posts: 85
Though could you not detect a browser refresh with a little help from the server side? This is what I did with the State Navigation pattern. I implemented the onload, and onunload events to pull and push the state of a page.
jimmy davids
Greenhorn

Joined: Mar 18, 2006
Posts: 1
http://www.whoopis.com/howtos/jscript-refresh-save.php
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overriding Browser refresh button