About closing browser exit system experience and methods of clearing session

Source: Internet
Author: User
1, first page Add the following code window.onbeforeunload = function (evt) {var evt = (evt)? evt:window.event;
if ($.browser.msie) {
Evt.cancelbubble = true;
Return "Are you sure you want to exit the system? ";
else if ($.browser.mozilla!= undefined) {
Evt.stoppropagation ();
var result = confirm ("Are you sure you want to exit the system?") ");
if (!result) {
return false;
} else {
Window.onunload = unload;
}
}
}
Window.onunload = function (evt) {
var evt = (evt)? Evt:window.event;
if ($.browser.mozilla!= undefined) {//Firefox clears this event to prevent bubbling
Window.onbeforeunload = function () {}
}
window.open ("/account/logoff/");
Window.opener = null; Window.close ();
//define two global variables that can be restored after the event is cleared.
var beforeunload = window.onbeforeunload;
var unload = window.onunload;     2, the page of a label "href" Set to "#", if there is a link, please use onclick.     3, if there are methods on the page to call Location.href, please clear two events before setting, or directly set to NULL. 4, if there are methods in the page to dynamically load IFRAME, please clear two events before loading, after loading completed, and then restore two events.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.