Window. Open open new window

Source: Internet
Author: User

First of all, I am a lazy person, so I am too lazy to knock on the keyboard. I don't know when I will take the test online. This is also a problem I encountered when I learned C, I wrote down the solution I found below. These things are helpful for beginners.

1. Basic description

1.1 method Signature: onewwindow = Window. Open (Surl, sname, sfeatures, breplace)
The method signature shows that window. Open opens a window (whose URL is Surl) and returns a variable representing the window object.
Onewwindow. If it cannot be opened successfully, the value of onewwindow is null. In addition, in order to control the Opened Window in advance
Other parameters (sname, sfeatures, and breplace) are available for configuration. The following describes the meaning of each parameter.

1.2 meanings of parameters

* Onewwindow: the object of the Opened Window
* Surl: the URL of the window to be opened
* Sname: the window in which the new URL link is opened, such as _ blank (new window) and _ top (outermost window ).
* Sfeatures: controls the window attributes.
O fullscreen: whether to use full screen mode (equivalent to F11). Optional values: yes/1 and no/0.
O directories: whether the directory button is included (for example, the 'linked 'directory in the favorites folder). The value can be the same as the preceding one.
O location: whether the address bar is included. The optional values are the same as the preceding values.
O channelmode: Specifies whether the cinema mode is used. The value can be the same as the preceding one.
O menubar: Indicates whether a menu bar exists. The optional values are the same as those in the preceding figure.
O resizable: whether the window size can be changed. The optional values are the same as those in the preceding figure.
O scrollbars: Indicates whether a scroll bar exists. The optional values are the same as those in the preceding figure.
O status: whether the status bar exists. The optional values are the same as the preceding values.
O titlebar: whether the title bar exists. The optional values are the same as those in the preceding figure.
O toolbar: whether to include a shortcut toolbar. The optional values are the same as those in the preceding figure.
O Height: window height
O width: window width
O top: distance from the edge of the screen
O left: distance from the left edge of the screen
* Breplace: if a new window is opened in the same window, this value is used to specify whether to replace the URL link of the original window in history. Optional values: True/false.

2. Basic usage

* Open a link (/myoa/admin/manage. jsp) in a new window)

Window. Open ("/myoa/admin/manage. jsp ");
Or
Window. Open ("/myoa/admin/manage. jsp", "_ blank ");
Note: In this case, a new window will be opened for each execution. Even if the previous window is not closed, a new window will pop up.

* Open a link (/myoa/admin/manage. jsp) in a specified window)

Window. Open ("/myoa/admin/manage. jsp", "mywiddown"); // mywindow is the name of the window.
Note: If the mywindow does not exist, a new window is displayed and named mywindow.
Do not close, then execute this open later. The pop-up window is the existing mywindow
In addition, some window names have been used by browsers and have special meanings, such as _ blank, _ top, _ parent, and _ self.

* Open a new window with a height of PX, a width of PX, no scroll bar, and no address bar (/myoa/admin/manage. jsp)

Window. Open ("/myoa/admin/manage. jsp", "_ blank", "Height = 300, width = 500, scrollbars = No, location = No ");
Note: sfeatures parameters are separated by commas. In window. showmodaldialog, they are separated by semicolons. Be sure to note!

3. Advanced

* Positioning of objects between the original window and the pop-up window
O Overview: the pop-up window is a frequently used method in page programming. From the perspective of interaction, there are two main pop-up windows: information display window, for example, personnel information and article information. For example, in some projects, the new article window is displayed. For the information display window, you can close it after reading it. However, after the user continues to process the window, he or she often needs to perform user actions with the original window, for example, when an article is created and submitted in a new window, you want to refresh the original window when the window is closed.
O solution: the Key of the above method is how to obtain the original window and pop-up window objects. We can clearly see in the DOM model:
+ Retrieve the pop-up window objects in the original window:

VaR infowindow = Window. Open ("Create. jsp", "_ blank", "width = 500, Height = 400 ″);
// Infowindow indicates the window object in the pop-up window. For example, if there is a form (myform) and an input control (username) in the form in the pop-up window, we can perform the following operations:
Infographic example Doc ument. myform. username. value = "Lisi ";

O get the original window object in the pop-up window:

For the above example, in create. jsp, We can refresh the original window as follows:
Opener. Location. Reload ();
// Opener is a default object provided by Dom, indicating the original window of a window.

* Wondow. Open cache Processing
O Overview: If window. the target of the open link specifies an existing window, especially a frame and IFRAME in the original page. the open link page will not be requested again from the server, but will use the corresponding cache page in the browser. At least ie gives people the feeling that, for example:

<Input type = "button" value = "display list" onclick = "window. Open ('/myoa/users/list. jsp', 'main',") "/>
<HR>
<IFRAME name = "Main" src = "/myoa/users/list. jsp" width = "100%" Height = "600" frameborder = "0"> </iframe>
The first time a list is displayed on this page, even if a new record is created, you will find that the list has not changed when you click "show list, in this case, close the browser and try again to find that the newly created record appears in the list. It can be seen that the cache plays a role.

O solution: In the experiment, we found that the medium-oriented link won't happen the above phenomenon. Every time we make a new request, we also use the above example. The following method is acceptable:

<A href = "/myoa/users/list. jsp" target = "Main"> display list </a>
<HR>
<IFRAME name = "Main" src = "/myoa/users/list. jsp" width = "100%" Height = "600" frameborder = "0"> </iframe>
However, in many cases, we do not use window. Open to access an IFRAME on this page (which you may encounter in the future), so the class can be solved as follows:

<Input type = "button" value = "display list" onclick = "document. getelementbyid ('showlist'). Click ()"/>
<A href = "/myoa/users/list. jsp" target = "Main" id = "showlist" style = "display: none"> display list </a>
<HR>
<IFRAME name = "Main" src = "/myoa/users/list. jsp" width = "100%" Height = "600" frameborder = "0"> </iframe>
The above example is relatively simple. In actual projects, you still need to do a lot of javascipt work before the hidden link is triggered.

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.