How to close the window in HTML (Classic + Useful + common)

Source: Internet
Author: User
Tags close close

Window. Close close the window. Close the window without a system prompt.
========================================================== ==============
When we use this method: Response. Write ("<SCRIPT> window. Close () </SCRIPT> ")
Always Prompt: the prompt that the webpage you are viewing is trying to close
How do I remove the prompt and close the form directly?
You can use the following methods:
Response. Write ("<SCRIPT> window. Opener = NULL; window. Close () </SCRIPT> ")
Only IE6 is supported.
Opener can be set to any value without any prompt

How can I close a parent form through a child form?
Subform (pop-up form ):
Likewise:
Response. Write ("<SCRIPT> window. opener. Top. Opener = NULL; window. opener. Top. Close () </SCRIPT> ")

========================================================== ================================
The simplest method is to close the window code without prompting (you can copy it directly ):
 
<Input type = "button" onclick = "window. Opener = 'xxx'; window. Close ();"
Value = "IE6 simplest window closed without prompt">
========================================================== ======================================
The following message is displayed when the window is closed:
<Input type = "button" onclick = "javascript: window. Close ();" value = "close">
<A href = "javascript: window. Close ();"> close </a>
========================================================== ======================================
Code for automatically closing the window:
<Script language = "JavaScript">
<! --
Function clock () {I = I-1
Document. Title = "this window will be closed automatically after" + I + "seconds! "
If (I> 0) setTimeout ("clock ();", 1000 );
Else self. Close ();}
VaR I = 20
Clock ();
// -->
</SCRIPT>
After the following code is added to the source code of the webpage, the window will be automatically closed in 20 seconds! This works well with a small pop-up window! In the Code, "I = 20" indicates that the delay for disabling is 20 seconds, which can be modified at will.
========================================================== ======================================
No operation prompt. The window is closed automatically.
<SCRIPT> setTimeout ("window. Opener = 'xxx'; window. Close ();", 1000); </SCRIPT>
========================================================== ======================================
How to hide the IE menu bar, toolbar, and address bar:
<Script language = "JavaScript">
<! --
Function mm_openbrwindow (theurl, winname, features) {// V2.0
Window. Open (theurl, winname, features );
}
// -->
</SCRIPT>

<A href = "javascript:;" onclick = "mm_openbrwindow('s.html ', 'yy', 'width = 300, Height = 300')"> link to the page address </a>
========================================================== ======================================
Set the window size and the window will be closed automatically without prompt:

<Body onload = "Top. resizeTo (300,300);">
<Div align = center> data is successfully inserted! <Br>
</Div>
<SCRIPT> setTimeout ("window. Opener = 'xxx'; window. Close ();", 2000); </SCRIPT>
</Body>
========================================================== ======================================
Click connection to bring up a specific window (hide the IE menu bar, toolbar, and address bar:

<A href = "s.html" onclick = "javascript: window. open (this. href, '_ blank', 'toolbar = No, location = No, directories = No, status = No, menubar = No, scrollbars = Yes, resizable = No, top = 0, left = 0, width = 790, Height = 545 '); Return false "> New window </a>
========================================================== ==================================
This section describes how to set the window size, ie menu bar, toolbar, and address bar:

You can use resizeTo () to set the window size. The resizeBy () function adds this code to the <Script language = JavaScript> resizeTo (x, y) </SCRIPT> or ()
X and Y are the length and width of the window you want. dx and Dy are the values you want to increase the length and width of the window. (Dx, Dy) is reduced when it is a negative number.
Hide the toolbar. You must open a new window in the menu bar (the following code may vary with the formats of different browsers for IE. Do not press enter to wrap the line after opening !)
Window. Open ("url", "window_name", "menubarbar = No, toolbar = No"> </SCRIPT> 〉
<SCRIPT> the URL is the address of the web page to be displayed in the new window, And window_name is the name of the window, which may be used for linking. If not, replace it, menubarbar (menu bar) toolbar (toolbar) locationbar (Address Bar) status (status bar) personalbar resizabla (whether to allow resizing) fullsreen (whether full screen) parameters can be used in the same format

If an error occurs during code execution, check whether there are extra spaces and the "<" ">", once I directly pasted the code on the web page, the "<"> "problem exists.

 

 

When we use this method: Response. Write ("<SCRIPT> window. Close () </SCRIPT> ")
Always Prompt: the prompt that the webpage you are viewing is trying to close
How do I remove the prompt and close the form directly?
You can use the following methods:
Response. Write ("<SCRIPT> window. Opener = NULL; window. Close () </SCRIPT> ")
Only IE6 is supported.
Opener can be set to any value without any prompt

How can I close a parent form through a child form?
Subform (pop-up form ):
Likewise:
Response. Write ("<SCRIPT> window. opener. Top. Opener = NULL; window. opener. Top. Close () </SCRIPT> ")

<Object ID = HH1 classid = "CLSID: ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<Param name = "command" value = "minimize"> </Object>
<Object ID = HH2 classid = "CLSID: ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<Param name = "command" value = "maximize"> </Object>
<Object ID = hh3 classid = "CLSID: adb880a6-d8ff-11cf-9377-00aa003b7a11">
<Param name = "command" value = "close"> </Object>

<Input type = button value = minimized onclick = hh1.click ()>
<Input type = button value = maximized onclick = hh2.click ()>
<Input type = button value = Disable onclick = hh3.click ()>

 

The simplest window. Close () Example: <a href = "javascript: window. Close ();"> close </a>
However, if you do not use window. open () to open a window, you will be prompted to remove it as follows: Method :

// Valid values for IE6 + SP1
<Object ID = closeit classid = "CLSID: adb880a6-d8ff-11cf-9377-00aa003b7a11">
<Param name = "command" value = "close"> </Object>
<A href = "javascript: closeit. Click ()"> click here to close the window. </a>

// Valid for ie5.5 or above
<Input type = button value = close onclick = "window. Opener = 'null'; window. Close ()">

// Valid for ie5.5 or above
<Object ID = webbrowser classid = CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2 Height = 0 width = 0> </Object> <input type = button value = Close Window onclick = document. all. webbrowser. execwb (45,1)>

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.