JavascriptshowModalDialog, open method to obtain the parent window _ javascript skills

Source: Internet
Author: User
ShowModalDialog: open obtains the code of the parent window. For more information, see. Window. open is usually used to open a new window.
To obtain the control of the parent window, you can use window. opener to obtain the parent window.
However, if showModalDialog is used, it is invalid.
If necessary, you need to modify the enabled syntax and the syntax in showModalDialog.
To enable the syntax for the 2nd parameters, see self. The example is as follows:
Var rc = window. showModalDialog (strURL, self, sFeatures );
Then there is the syntax for calling the parent window.
Var pWindow = window. dialogArguments;
In this way, the window object control of the parent window can be obtained. For example:
Optional values dialogarguments.doc ument. getElementsByName ("processId") [0]. value;

Differences Between opener and parent in js

Opener is who opens my window. For example, if window. open is used to pop up the B page window on page A, the window where page A is located is the B page
Opener: You can access page A through the opener object on page B.
Parent indicates the parent window. For example, if A page A uses iframe or frame to call page B, the window where page A is located is
Parent.
In JS, window. opener only references the parent window of the pop-up window. For example:
A.html, click "click" and click "other" to open a new window B .html. In B .html, you can use
When using opener(specifically, using opener.pdf to reference a.html, including a.html documentobjects, and operating a.html content.
If this reference fails, null is returned. Therefore, before calling the opener object, you must first determine whether the object is null. Otherwise
The JS error "the object is null or does not exist" is displayed.

The Code is as follows:








Back2opener.html

The Code is as follows:








Window. opener returns the reference of the window that creates the current window.
B .htm, then we can input a value on B .htmand assign it to a textbox with the id "name" on a.htm.
Written:
Optional values opener.doc ument. getElementById ("name"). value = "input data ";

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.