OA Credit Disk Two-sided disk source building step JS How to close the current browser window

Source: Internet
Author: User
I want to create a link on the Web page that closes the current active tab in the browser without closing the other tabs in the browser. When the user clicks the close link, a prompt message appears asking the user to confirm with "YES" and "NO" two buttons. If the user clicks Yes, closes the page and, if no, does nothing.

How to do it? Do you have any suggestions?

You will need to use JavaScript to do this. OA Credit Disk Two-sided disk source building bbs.yasewl.com Please add link description use Window.close () method

Close ();
Note: The current label is implied. This is equivalent to:

Window.close ();
Or you can specify a different window.

Such as:

function Close_window () {
if (Confirm ("Close Window?")) {
Close ();
}
}
Html:

<a href= "Javascript:close_window (); >close</a>
Or:

<a href= "#" onclick= "Close_window (); return false;" >close</a>
return false here to prevent the default behavior of the event. Otherwise, the browser jumps to that URL.

Now the options on the Window.confirm () dialog box will be OK and cancel (not and no). If you do need yes and no, you need to create a JavaScript dialog box for a pattern.

Note: There are different browser differences than the above. If you use JavaScript (via window.open ()) To open the window, you can close the window with JavaScript. Firefox does not allow you to close other windows. I believe IE will ask the user to confirm. Other browsers may vary.

OA Credit Disk Two-sided disk source building step JS How to close the current browser window

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.