window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;
}
window.onbeforeunload = function() {
// This template uses no error checking, it's just concept code to be
// expanded on.
// Create a new XMLHttpRequest object
var AJAX=new XMLHttpRequest();
// Handle ready state changes ( ignore them until readyState = 4 )
AJAX.onreadystatechange= function() { if (AJAX.readyState!=4) return false; }
// we're passing false so this is a syncronous request.
// The script will stall until the document has been loaded.
// the open statement depends on a global variable titled _userID.
AJAX.open("GET", 'http://someurl.com/endsession.php?id='+_userID, false);
AJAX.send(null);
}
http://snippets.dzone.com/posts/show/142
http://www.webdeveloper.com/forum/showthread.php?t=130767
http://www.codeproject.com/KB/aspnet/NavAwayFromPage.aspx
http://www.hunlock.com/blogs/Mastering_The_Back_Button_With_Javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment