JavaScript Window opener Property

The JavaScript Window opener property refers to the window or frame that opened the current window. It is commonly used to access and manipulate the parent window from a child window or frame.

Here are some examples of how the opener property can be used in JavaScript code:

  1. To access the parent window from a child window, you can use the following code:
var parent = window.opener;

// you can now access the parent window's properties and methods
parent.document.getElementById('myElement').innerHTML = 'hello';
  1. To close the parent window from a child window, you can use the following code:
var parent = window.opener;

// you can now close the parent window
parent.close();
  1. To access the parent window’s variables from a child window, you can use the following code:
var parent = window.opener;

// you can now access the parent window's variables
var parentVariable = parent.myVariable;

Overall, the opener property provides a convenient way to access and manipulate the parent window from a child window or frame. It can be used to pass data, execute functions, or perform other tasks on the parent window.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: