First, avoid pop-up prompt box
Search on the Internet a lot, the answer is mostly set window.onbeforeunload=null, but after the trial is invalid.
After two days of this question returned to think again, finally found the answer, here and share with you:
Remove jquery from the page eject (1) first unbind the set popup content to null.
Copy Code code as follows:
$ (function () {
$ (window). Unbind (' Beforeunload ');
Window.onbeforeunload = null;
})
Ii. other relevant [abstract]
(1)window onunload and onbeforeunload events
Here is the implementation in JS, rather than <body onunload= "close ()" > This method!
Because this is unload drop body when the trigger, and no matter any browser, will be closed when the unload off the body!
Model 1:
Copy Code code as follows:
function Close () {
Alert ("This is a Test");
}
Window.onbeforeunload=close;
Model 2:
Copy Code code as follows:
function Close () {
if (document.body.clientwidth-event.clientx< 170&&event.clienty< 0| | Event.altkey)
{
Alert ("This is a Test");
}
}
Window.onbeforeunload=close;
Copy Code
About Model 1:
1. Refresh, multiple windows and Single Window fit.
2. Single Window IE closes the entire IE trigger.
3). IE7 to close a single page trigger in multiple windows
4 other multiple Windows refresh triggers. Turn off the individual and close the whole without triggering
For Model 2:
1. IE Single window and IE7 multiple windows, to close the entire browser before triggering
2. Other multi-window browser refreshes. Close a single page, close the whole without triggering
(2) Create a departure cue box
Binding Beforeunload Events
Copy Code code as follows:
$ (window). bind (' Beforeunload ', function () {
Return ' You have entered the content has not been saved, OK to leave this page? ';
});
Unbind
Copy Code code as follows:
$ (window). Unbind (' Beforeunload ');
Window.onbeforeunload = null;
The above is the full content of this article, I hope you can enjoy.