Javascript Browser Window parent Property

Introduction

Change the background-color of an <iframe> element's parent document:

parent.document.body.style.backgroundColor = "red";

Click the button inside the iframe to change the background color of the iframe's parent document.

View in separate window

<!DOCTYPE html>
<html>
<body>

<iframe id="myframe" src="demo_iframe2.htm" width="100%" height="500" style="background:#f1f1f1;">
  <p>Your browser does not support iframes.</p>
</iframe>//from  w  w  w .ja va2s  .co  m
</body>
</html>

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

This property is read-only.




PreviousNext

Related