Add an event using JS to the browser's Close button

Source: Internet
Author: User

The following refers to the implementation in JS, not <body onunload= "close ()" > This method!

Because this is the unload drop body when triggered, and bored any browser, will be closed when the body unload off!

Model 1:
function Close () {
Alert ("Sdfsdfsdf");
}
Window.onbeforeunload=close;

Model 2:
function Close () {
if (document.body.clientwidth-event.clientx< 170&&event.clienty< 0| | Event.altkey)
{
$ ("#logout1"). Submit ();
}
}
Window.onbeforeunload=close;

<form action= "/home/logout1" id= "LOGOUT1" ></form>

Jump directly to the LOGOUT1 controller for various operations

For model 1:
1). refresh, Multi-window and Single window are suitable.
2). Single Window IE turns off the entire IE trigger.
3). IE7 Close Single-page trigger in multiple windows
4) Other multi-window refresh triggers. Close the individual and close the whole without triggering

For Model 2:
1). IE Single window and IE7 multiple windows, all to close the entire browser to trigger
2). Other Multi-window browser refresh. Close a single page, close the whole without triggering

PS: The second method is recommended

Excerpted from http://www.cnblogs.com/zgqys1980/archive/2008/09/02/1281843.html

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.