JavaScript Showmodaldialog,open ways to get the parent window _javascript tips

Source: Internet
Author: User
Usually open a new window using a window.open method.
To get the control of the parent window, you can use Window.opener to get the parent window
However, if you use ShowModalDialog ... is not valid
If necessary, you need to modify the open syntax and the syntax in ShowModalDialog
Open syntax The 2nd argument please go to self, example below
var rc=window.showmodaldialog (strurl,self,sfeatures);
And then there's the syntax to call the parent window.
var pwindow=window.dialogarguments;
This allows you to get control of the window object for the parent windows. For example:
Window.dialogArguments.document.getElementsByName ("ProcessID") [0].value;

the difference between opener and parent in JS

Opener that who opened my, such as a page using window.open pop-up b page window, then a page is the window is b page
Opener, you can access page A on the B page through the opener object.
Parent, such as a page with an IFRAME or a frame to call B page, then a page is the window is the B page
Parent
In JS, Window.opener is just a reference to the pop-up window's parent window. Like what:
In A.html, window.open a new window b.html by clicking on a button. Then in the b.html, you can pass
Window.opener (omitted to be written as opener) to refer to a.html, including a.html document and other objects, to manipulate the contents of a.html.
If this reference fails, then NULL is returned. So before you call the opener object, you have to determine whether the object is null, or you will
A JS error with "object is empty or does not exist" appears.
Copy Code code as follows:

<body>
<form. Name=form1>
<input Type=text Name=inpu >
<input Type=button >
</form>
</body>

Back2opener.html
Copy Code code as follows:

<body>
<form. Name=form1>
<input Type=text Name=inpu >
<a class=under href=# > Add </a>
</form>
</body>

Window.opener returns a reference to the window that created the current window, such as clicking a link on the a.htm and opening the
B.htm, then we're going to enter a value on the b.htm and then give the a.htm a textbox with the ID "name" to
Write as:
Window.opener.document.getElementById ("name"). Value = "entered data";
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.