JavaScript does not prompt to close the window, compatible with IE and Firefox

Source: Internet
Author: User

Method 1:

This method is successfully tested in IE7.
< Html >
< Head >
< Meta HTTP-equiv = "Content-Type" Content = "Text/html; charset = gb2312" >
< Title > Close the window without mentioning </ Title >
</ Head >
< Body >
< Script Language = "JavaScript" Type = "Text/JavaScript" >
FunctionClose ()
// Close the current window
Window. Open ('', '_ parent ','');
Window. Close ();
Function openwin (URL)
// Open the window in full screen, URL
Window. Open (URL, '_ blank', 'fullscreen = 1 ');
Close ();
</ Script >
< Input Type = "Button" Value = "Close" Onclick = "Close ();" />
</ Body >
</ Html >

Method 2:

1. Set the following sectionCodeAdd it to the worker where you want to close the IE window:
Geturl ("Javascript: Window. Opener = NULL; window. Close ();");

2. Add the following code to your button:
On (release ){
Geturl ("Javascript: Window. Opener = NULL; window. Close ();");

This cannot directly close the window opened by IE!
<Object ID = "webbrowser" width = 0 Height = 0 classid = "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2">
<Input type = "button" name = "button" value = "Close Window" onclick = "document. All. webbrowser. execwb (45,1)">

Method 3:

If you press window. Close () on a page that is not opened by JS, there will be a prompt box, which is annoying. Now you don't need it. Close the window without a prompt box.

Try the following code:

<Object ID = webbrowser width = 0 Height = 0 classid = CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2>
<Input type = button name = button value = Close Window onclick = Document. All. webbrowser. execwb (45, 1)>

If you try to change the parameters, you will get some other functions:

Webbrowser. execwb () Open
Webbrowser. execwb () Close all existing IE Windows and open a new window
Webbrowser. execwb () Save the webpage
Webbrowser. execwb (6, 1) print
Webbrowser. execwb (7,1) print preview
Webbrowser. execwb (8, 1) print page settings
Webbrowser. execwb (10, 1) view page properties
Webbrowser. execwb () seems to be undo, to be confirmed
Select All webbrowser. execwb (17,1)
Webbrowser. execwb (22, 1) Refresh
Webbrowser. execwb () Close form no prompt

These are only valid for ie5.5 and later versions. I tested them in IE6 and passed them.

Related Article

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: 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.