JavaScript windows.open (), Windows.close () method _javascript Skills

Source: Internet
Author: User

The Windows.open () method is detailed:

The window.open (url,name,features,replace) is used to load the specified URL into a new or existing window and return a Window object that represents the new windows. It has 4 optional parameters:

URL: An optional string that declares the URL of the document to display in a new window. If this argument is omitted, or if its value is an empty string, the new window will not display any documents.

Name: An optional string that is a comma-delimited list of features that includes numbers, letters, and underscores that declare the name of the new window. This name can be used as the value of target for tags <a> and <form> properties. If the parameter specifies a window that already exists, the open () method uses the window directly. In this case, the features parameter of the specified window feature is ignored. Reserved name: "_ Blank", "_ Parent", "_ Top" refers to the new window display position.

Features: (non-standard, recommended to ignore this parameter) an optional string that declares the characteristics of the standard browser to be displayed for the new window. If this argument is omitted, the new window will have all the standard features. In the following window features in this table, we describe the format of the string in detail.

Replace: An optional Boolean value. Specify whether the URL loaded to the window creates a new entry in the window's browsing history or replaces the current entry in the browsing history. Supported values: True-url replaces the current entry in the browsing history; False-url creates a new entry in the browsing history.

The new top-level browser window is created by Method window.open (). When this method is invoked, the return value of the open () call should be stored in a variable, and then the new window will be referenced using that variable. The opener property of the new window, in turn, references the window that opened it.

Do not confuse the method window.open () with the method Document.open (), which has a completely different function. To make your code clearly clear, use window.open () instead of open ().

Most browsers add pop-up filtering systems. Usually the open method is invoked only when the user manually clicks the button or link. JavaScript code often fails when it tries to open a pop-up window when the browser initially loads (or unloads).

Window features (Windows Features)

Channelmode=yes|no|1|0 whether to use Theater mode to display windows. The default is No.

Directories=yes|no|1|0 whether to add a table of contents button. The default is yes.

Fullscreen=yes|no|1|0 whether to display the browser using Full-screen mode. The default is No. A window in Full-screen mode must be in theatre mode at the same time.

The height of the Height=pixels window document display area. In pixels.

The x-coordinate of the Left=pixels window. In pixels.

Location=yes|no|1|0 whether the Address field is displayed. The default is yes.

Menubar=yes|no|1|0 whether the menu bar is displayed. The default is yes.

Resizable=yes|no|1|0 whether the window can be resized. The default is yes.

Scrollbars=yes|no|1|0 whether scroll bars are displayed. The default is yes.

Status=yes|no|1|0 whether to add a status bar. The default is yes.

Titlebar=yes|no|1|0 whether the title bar is displayed. The default is yes.

Toolbar=yes|no|1|0 whether to display the toolbar of the browser. The default is yes.

The y-coordinate of the Top=pixels window.

The width of the document display area of the Width=pixels window. In pixels.

Window.close () Method:

If you have created a Windows object W, you can close the window w.close (), and in this window use Window.close ();

Note: the Window.close () method must be explicitly invoked to avoid confusion with the document.close () method;

Most browsers only allow scripts to automatically close Windows created by scripts, and if you want to close other windows, you can use a dialog box to get the user's confirmation or cancellation; Window.close () cannot close a form embedded in a window;

Even if a window is closed, the Window object that represents it still exists. A closed window will have a closed property with a value of true, its document will be NULL, and its methods will not normally work again.

The above is a small set to introduce the JavaScript windows.open (), Windows.close () method of explanation, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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