This article mainly introduces the implementation code of page closure and page refresh in JavaScript, which will be used in some special occasions, for more information, see <G id = "1"> </G>.
Although there is no direct method, it can be achieved through certain skills
I have to lament the power of JavaScript !!
Take a look at the Code:
The Code is as follows:
Window. onunload = function (){
Var a_n = window. event. screenX-window. screenLeft;
Var a_ B = a_n> document.doc umentElement. scrollWidth-20;
If (a_ B & window. event. clientY <0 | window. event. altKey ){
Alert ('closing page activity ');
} Else {
Alert ('jump to or refresh the page ');
}
}
In fact, it is to detect the window size of the browser by leaving the page Behavior Time onunload trigger time. Based on the size, it is determined that the user is refreshing, redirecting, or disabling the behavior.
Compatible with various browsers!