I happened to see window.opener in another article. I don’t know what I’m talking about.

Window.opener returns a reference to the window in which the current window is opened.

  • If the current window is opened by another window,  window.opener A reference to that window is preserved

  • This property returns if the current window is not open by another windownull

var objRef = window.opener;Copy the code

There are several ways to open a new window:

  • window.open()

    • Open a new TAB
    • A new browser window opens
  • Hyperlink:<a href="www.xxx.com" target="_blank">Click Me</a>

Window.opener gets the correct reference to the source window for any method of opening a new window.