The use of JS opener detailed

Source: Internet
Author: User

  in JS, Window.opener is just a reference to the pop-up window's parent window. This article is mainly on the use of JS opener in detail, the need for friends can come to the reference, I hope to help you.

In JS, Window.opener is just a reference to the pop-up window's parent window. For example: a.html, by clicking the button and so on to window.open out a new window b.html. Then in b.html, we can use Window.opener (omit write as opener) to reference a.html, including a.html document and other objects, manipulate a.html content. If this reference fails, then NULL is returned. Therefore, before calling the opener object, you must first determine whether the object is null, otherwise the "object is empty or does not exist" JS error.   Example opener.html     code as follows: <html> <body> <form name=form1> <input type=text Name=inpu & Gt <input Type=button  onclick= "Javascript:window.open (' Back2opener.html?toname=opener.form1.inpu ');" > </form> </body> </html>   back2opener.html code is as follows: <html> <body> <form name= form1> <input type=text name=inpu >   <a class=under href=# onclick= "{Opener.document.form1.inpu.value + = ' Sun Chao, ';} ' > Add </a> </form> </body> </html>     JS code:  window.open ();  and when payment is successful, Need to close payment platform payment successful interface, and client load client to pay Success page, JS code:  window.opener.location.href=url;window.close (); 

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.