Js monitors the closing refreshing backtracking and forward events of the Internet explorer firefox browser
2020-03-30 03:36:20
OfStack
<html>
<head>
<title>test</title>
<script language ="javaScript">
<!-- Close the browser -->
var flag = true;
window.onbeforeunload = function () {
if (flag) {
var evt = window.event || arguments[0];
var userAgent = navigator.userAgent;
if (userAgent.indexOf("MSIE") > 0) {
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth - 20;
if (b && window.event.clientY < 0 || window.event.altKey) {
window.event.returnValue = (" This action will cause an abnormal exit from the system ( Correct way to exit the system: click the exit button ) Are you sure ?");
}else {
return (" This action will cause an abnormal exit from the system ( Correct way to exit the system: click the exit button ) Are you sure ?");
}
}else if (userAgent.indexOf("Firefox") > 0) {
return (" This action will cause an abnormal exit from the system ( Correct way to exit the system: click the exit button ) Are you sure ?");
}
}
}
</script>
</head>
<body>
dengyang
<body>
</html>