Javascript Reference - Window parent Property








The parent property returns the parent window of the current window.

Browser Support

parent Yes Yes Yes Yes Yes

Syntax

window.parent

Return Value

The parent window of the current window.

Example

The following code shows how to output the location of the parent window when opening the new window.

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<!--from   ww w.j  a v  a2 s. c o  m-->
<script>
function myFunction() {
    window.open("", "", "width=200, height=100");
    console.log(window.parent.location);
}
</script>

</body>
</html>

Click to view the demo