JavaScript window.parent Property

You are Here:

JavaScript window.parent Property

The window.parent property returns a reference to the parent of the current window or subframe.

Note: If a window does not have a parent, its parent property is a reference to itself.

Note: When a window is loaded in an <iframe>, <object>, or <embed>, its parent is the window with the element embedding the window.

Example

The is another web page iframe.html.

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var x = window.parent.document.getElementById("point"); x.style.color = "red"; </script> </body> </html>

This example will demonstrate how window.parent will effect on its parent window.

HTML Online Editor
<!DOCTYPE html> <html> <body> <p>I will not change color</p> <p id="point">I will change color.</p> <iframe src="/js/window-parent/iframe"> Your browser do not support iframe. </iframe> </body> </html>

Syntax

window.parent

Return Value

ValueExplanation
ObjectReturns a reference to the parent of the current window or subframe.

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author