The call method between the parent and child forms of JavaScript

  • 2020-05-24 05:10:36
  • OfStack

This article demonstrates an example of how to call between the parent and child forms of JavaScript. Share with you 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. The parent form

To make it easier for the parent window to manipulate the child window, you can define a variable for the window.open () method, such as:


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

To close the child window, you can use the opW.close () method directly.

If the parent form wants to manipulate the child window element, the code is as follows:

opW.document.getElementById("fartherWindowTxt").innerHTML = " Operand subwindow ";

2. Child form

Child Windows can use window.opener to reference the parent window. The code is as follows:

window.opener.document.getElementById("fartherWindowTxt").innerHTML= " Child window operation parent window! ";

I hope this article has helped you with your javascript programming.


Related articles: