In the below code, the function closeWin() is being called all of a sudden in the middle of the page navigation. This is not happening always on one page.
<html>
<head>
<script language="JavaScript">
function closeWin() {
var size = document.body.offsetWidth-32;
if (event.clientY < 0 && event.clientX >= size) {
event.returnValue = false;
event.returnValue = 'Do you want to leave this page?';
return false;
}
}
</script>
</head>
<body onbeforeunload="return closeWin();">
.....
</body>
</html>
Is there any problem in the above code?
Any suggestions are helpful.



Reply With Quote
Finally, return the string value from the function (not a boolean), and delete the assignments to the returnValue property. You only need to do one or the other, and the latter is better in my opinion.
Bookmarks