Tuesday, October 31, 2006

Javascript code for Confirm leaving page (like editing blogspot.com )

If you are editting your blog at blogspot.com your browser would ask your confirmation if you'r not yet saved your modification.
Here's the javascript code
< script type="text/javaScript" >
var needToConfirm = true;
window.onbeforeunload = confirmExit;

function confirmExit() {
if (needToConfirm)
doyou = confirm('Are you sure you wish to leave this page?\n\nLeaving this page now will result in any data that you have already entered being lost.');

if (doyou == false)
return false;
}
</script>
a litle modification on this script will do better.
<script type="text/javaScript">
var needToConfirm = true;
window.onbeforeunload = confirmExit;

function confirmExit() {
if (needToConfirm)
doyou = false;

if (doyou == false)
return false;
}
</script>
too bad we cant customized the message.
The script will display this confirmation message "are you sure you want to navigate away from this page?
press ok to continue, or cancel to stay on the current page"
if anyone know how, please reply to this post

1 comment:

Hannah Martinez said...

For those who appreciate distinctive timepieces, Coveted offers an astounding array. The striking Hublot Big Bang Unico is notable for its groundbreaking design. If you're into diving, the iconic Blancpain Fifty Fathoms Bathyscaphe is a must-see. The sophisticated Omega Seamaster Aqua Terra suits daily wear beautifully. Additionally, the timeless Rolex Datejust 36 remains perpetually in vogue.