JavaScript about window.open () application

Source: Internet
Author: User
Tags string window
Javascript|window

Web pages are built on top of the window, and anything about the page is related to the window. Let's begin by familiarizing ourselves with the basic structure of the Internet Explorer that you commonly use.

Normally, open windows have the following four parts:

  • Title bar: This window shows the location of the title
  • Control Area: various buttons, menus
  • Window: The biggest part of the browser, needless to say it!
  • Status bar: Places to display appropriate system information and JavaScript information

    By default, open new Windows contain the above sections. But when you use Windows. Open (), we can control the style of the newly opened window.

    Grammar:

    Onewdoc = document. Open (surl [, sname] [, Sfeatures] [, breplace])

    Description

    sURL Optional. String --Specifies the URL address of the new document. If this item is not specified, it will be an empty (About:blank).
    Sname Optional. string -the name of the newly generated window. Can be used as a value for the form or target in a.
    Blank sURL is loaded into a new unnamed window.
    _media The surl is loaded into a media bar. (only for IE6 and later versions of browsers)
    _parent The surl is loaded onto the upper frame of the current frame. If there is no upper frame, the value of this item is the same as the value of _self.
    _search sURL is opened in the browser's lookup window. (For IE5 and later browsers only)
    _self sURL opens on the current window, overwriting the previous content.
    _top sURL may be loaded onto any frame bracket (Frameset), and if Frameset is not defined, this value is the same as the _self value.
    Sfeatures Optional. string --Lists the object tables and separates them with commas. Each item has its own value, and they will be separated (e.g. "fullscreen=yes, Toolbar=yes"). Here are the various features that are supported.
    Channelmode = {Yes | no | 1 | 0} Whether to display the Step mode in the window. The default is no.
    directories = {Yes | no | 1 | 0} Whether to display various buttons in the window. The default is Yes.
    fullscreen = {Yes | no | 1 | 0} Whether to display the browser in Full-screen mode. The default is No. You need to be very careful when using this feature. Because this property may hide the browser's title bar and menu, you must provide a button or other hint to help the user close the browsing window. ALT+F4 can close the window. A full-screen window must use the step (channelmode) mode.
    Height = number Specifies the height of the window, in pixels. The minimum value is 100.
    left = number Specifies the distance, in pixels, of the window from the left border. Value must be greater than or equal to 0.
    Location = {Yes | no | 1 | 0} Specifies whether the address bar is displayed in a window. The default is Yes.
    menubar = {yes | no | 1 | 0} Specifies whether the menu bar is displayed in the window. The default is Yes.
    resizable = {Yes | no | 1 | 0} Specifies whether to display a handle in the window that can be resized by the user. The default is Yes.
    scrollbars = {yes | no | 1 | 0} Specifies whether to display a horizontal or vertical scroll bar in a window. The default is Yes.
    Status = {Yes | no | 1 | 0} Specifies whether the status bar is displayed in the window. The default is Yes.
    titlebar = {Yes | no | 1 | 0} Specifies whether the title bar is displayed in the window. This item is ignored if you are not calling an HTML application or a dialog box. The default is Yes.
    toolbar = {Yes | no | 1 | 0} Specifies whether to display a toolbar in a window, including buttons such as forward, rewind, stop, and so on. The default is Yes.
    top = number Specifies the position at the top of the window, in pixels. Value must be greater than or equal to 0.
    width = number Specifies the width of the window, in pixels. The minimum value is 100.
    Breplace Optional. When sURL is loaded into the same window, the boolean variable Specifies whether the sURL creates a new entry, or adds it to the current history of the window.
    True sURL Overwrites the history of the current document.
    False sURL creates a new entry in the history record.

    Comments:

    By default, theopen method creates a window with the default width, height, menu, and toolbar. You can specify any one or more of the feature parameters. These parameters are composed of one or more strings.

    When a characteristic parameter is specified, the other feature parameters not specified are all prohibited. Therefore, when you use the feature parameters, you need to define all the other feature parameters that need to be used in the window. If you do not specify a feature parameter, all of the features will be retained in the original default value. In addition to assigning new values to the feature parameters, you can also simply list the feature names to make the corresponding features of the window valid.

    Example:

    window. Open ("sample.htm",null,
    "Height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");

    In the example, a new window containing sample.htm is established. The new window has 200 like pixels and 400 pixels high, with a status bar, but no toolbars, menu bars, and address bars. The above code is the corresponding.

    Here is a more complete example, for you to refer to the new Window generation method.

    <title>Open Window</title>
    <script language="JavaScript">
    function Openwindow ()
    {
    Thiswin = window. Open ("", null, "width=300,height=400")
    Thiswin. document. Write (")
    Thiswin. document. Write ("<body><center>this is a new window!</center></body>")
    }
    </script>


    <body>
    <center>
    <input type="button" value="creat New window" OnClick="Openwindow ()">
    </center>
    </body>

    Example of this . Document. write writes code to a newly generated window, and if not, the newly generated window will display an error.

    The generation of new windows is relatively simple, as long as we master the characteristics described above, basically can be said to have mastered the new window generation method.

      Note: This series of JavaScript introductions is for beginners, so I'm talking about the most basic stuff. The goal is just to make the people who are learning web-making more likely to improve faster. Can only say that the object is different, so the level is also different, please everyone master consultation fee.



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