Window opener Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window opener

Description

The opener property returns a reference to the window that created the window.

Return Value

A reference to the window that created the window

Write some text to the source (parent) window:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*from w w  w  .  j  a va2 s.co m*/
    var myWindow = window.open("", "myWindow", "width=200,height=100");
    myWindow.document.write("<p>This is 'myWindow'</p>");
    myWindow.opener.document.write("<p>This is the source window!</p>");
}
</script>

</body>
</html>

Related Tutorials