Use of Window.opener and window.open

Source: Internet
Author: User

Use of Window.opener and window.open

Window.opener refers to the window that invokes the Window.Open method. Window.opener returns a reference to the window that created the current window, such as clicking on a link on a.htm and opening the b.htm, and then we're going to enter a value on the b.htm and give it a TextBox with an ID of "name" on the a.htm, It can be written as: Window.opener.document.getElementById ("name"). Value = "input data"; In the work is mainly used to solve the partial submission. If you open a page in the main window and want to refresh the main window with this, the Window.opener of the open page is equivalent to the window of the main windows. The main window of the refresh you can use Window.opener.location.reload (); If you use a virtual directory: such as struts *.do will prompt you to retry you can change to this window.opener.yourformname.submit () just fine. In the application there is a case in the A window open b window, in the b window after the completion of the b window, and automatically refresh a window.

The most basic pop-up Code: window.open (' page.html '), after setting the popup window window.open (' page.html ', ' newwindow ', ' height=100, width=400, Top=0, Left=0, Toolbar=no, Menubar=no, Scrollbars=no, Resizable=no, Location=no, Status=no ')//This sentence is written in a line of code


Parameter explanation:
window.open the command that pops up the new window;
The filename of the ' page.html ' pop-up window;
The name of the ' NewWindow ' pop-up window (not the file name), not required, available empty ' ' instead;
height=100 window height;
width=400 window width;
The pixel value of the Top=0 window from the top of the screen;
The pixel value of the left=0 window from the left side of the screen;
Toolbar=no whether the toolbar is displayed, yes is displayed;
Menubar,scrollbars represents the menu bar and scroll bar.
Resizable=no whether the window size is allowed to change, yes is allowed;
Location=no whether the address bar is displayed, yes is allowed;
Status=no whether the information in the status bar is displayed (usually the file is already open), yes is allowed;
--------------------------------------------------------------------------------
windows.location.href= "/url"
The current page opens the URL page;
Window.location.href=window.location.href, and Window.location.Reload () both refresh the current page. The difference is whether there is data to submit. When there is data submitted, Window.location.Reload () will prompt whether to commit, window.location.href=window.location.href, or submit data to the specified URL.
--------------------------------------------------------------------------------
There are no character types in JS, only string types.

Use of Window.opener and window.open

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.