stopping a page refresh
I found myself having to trap a user attempting to refresh a page for one of our web apps. After a little bit of digging I stumbled across this solution:
<script type=”text/javascript”> <!– window.onbeforeunload = unloadMess; function unloadMess(){ mess = “You are about to refresh the screen and will loose all of your changes.nAre you sure you want to do so?” return mess; } //–> </script>
To use it simply embed or include it into your template
Eventhough the article says this is a IE specific event/feature it also works in FireFox. You should be aware that whenever the user leaves the page, they will be prompted about their impeding data loss, which can get a little tedious while developing.
Again this became a handy feature for our AJAX apps as most of the processing is done in the background without the page reload, a user could accidentally hit the back button and loose where they were at.
About this entry
You’re currently reading “stopping a page refresh,” an entry on gregs
- Published:
- Friday, October 21st, 2005 at 12:00 am
- Author:
- gregs
- Category:
- Uncategorized
No comments
Jump to comment form | comments rss | trackback uri