Home  >  Article  >  Web Front-end  >  Detailed explanation of the use of js opener_javascript skills

Detailed explanation of the use of js opener_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:04:171136browse

In JS, window.opener is just a reference to the parent window of the pop-up window. For example: In
a.html, window.open opens a new window b.html by clicking a button. Then in b.html, you can reference a.html through window.opener (omitted and written as opener), including the document and other objects of a.html, and operate the content of a.html.
If this reference fails, null will be returned. Therefore, before calling the opener object, you must first determine whether the object is null, otherwise a JS error of "the object is empty or does not exist" will occur.

Example
opener.html

Copy code The code is as follows:










back2opener.html
Copy code The code is as follows:




Add





JS code:
window.open();
When the payment is successful Afterwards, you need to close the payment platform payment success interface and load the client payment success page on the client. JS code:
window.opener.location.href=url;window.close();
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn