Home > Web Front-end > JS Tutorial > body text

JavaScript calling method between parent and child forms_javascript skills

WBOY
Release: 2016-05-16 16:06:50
Original
1096 people have browsed it

The example in this article describes the calling method between JavaScript parent and child forms. Share it with everyone for your reference. The details are as follows:

If you want to open a new window, use the window.open() method.

If you want to close your own window, use the window.close() method.

1. Parent form

In order to facilitate the parent window to operate the child window, you can define a variable for the window.open() method, for example:

var opW = window.open("tests.html","popup","width=300,height=300");
Copy after login

In this way, to close the sub-window, you can directly use: opW.close() method.

If the parent form wants to operate child window elements, the code is as follows:

Copy code The code is as follows:
opW.document.getElementById("fartherWindowTxt").innerHTML = "Operation Child Window" ;

2. Subform

The child window can use window.opener to reference the parent window, the code is as follows:

Copy code The code is as follows:
window.opener.document.getElementById("fartherWindowTxt").innerHTML= "Child window Operate the parent window! ";

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!