June 8, 2000 - The opener Property
June 8, 2000|
The opener Property
Tips: June 2000
Yehuda Shiran, Ph.D.
openerproperty sets or retrieves a reference to the window that created the current window. When a source document opens a destination window by calling the
openerproperty (of the destination window's
windowobject) specifies the window of the source document. This property persists across document unload in the opened window, so it can be accessed even if the URL in the new window is changed.
opener property is a reference to the parent window's
window object. You can take advantage of this property to perform any action on the opener window via a script in the new window. For example, use the following script in the destination document to change the background color of the window that opened it:
if (window.opener && !window.opener.closed) window.opener.document.bgColor = "beige";
Notice that we must check if the opener window still exists before attempting to access its properties.
For a live demo of an application that uses the
opener property, go to Tutorial 1, Working with Windows.