If you need to display a confirmation before the user closes the window, you can use the beforeunload event of the window object to display a confirmation message.
JavaScript:
function AddUnloadHandler()
{
AddEventHandler(window, 'beforeunload', HandleUnload);
}
function HandleUnload()
{
var strConfirm = 'Please make sure you saved your changes before
closing the page.';
if (document.all)
{
window.event.returnValue = strConfirm;
}
else
{
alert(strConfirm);
var evnt = arguments[0];
evnt.stopPropagation();
evnt.preventDefault();
}
}
ASPX:
<body onload="AddUnloadHandler()">
Monday, March 10, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment