Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
Window.close not working for rel="noreferrer" but works with rel="opener"

Recently, at work, i made a redirection to another site. The maintainers of the other site contacted me and told me that their window.close are not working anymore. Here is a simple explanation of the problem:

let's say site A has an <a href="http://siteB" target="_blank" rel="noreferrer"> tag to navigate to the home page of site B. In the home page of site B, when you use window.close(), the window is closed. Now,(still in the site B), when the user navigates to another page (let's say /about page), a window.close in this page will not work. Chrome shows this warning:

Scripts may close only the windows that were opened by it.

But in the <a> tag, when i replaced rel="noreferrer" by rel="opener", window.close works in any page of the site B. For rel="noreferrer", window.close only works in the first page of the redirection. If i understand well the warning message, it's because the /about page was not opened by the site A, that's why window.close will not work in that page. But my question is, why by just changing rel="noreferrer" to rel="opener", window.close now works everywhere in site B?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In documentation of rel in mozilla there's saying rel="noopener" or rel="noreferrer"

Creates a top-level browsing context that is not an auxiliary browsing context.

The window opened like that has a top-level context.

But for rel="opener"

Creates an auxiliary browsing context.

It means it's not a top-level.

And now for documentation of window.close() there is

This method can only be called on windows that were opened by a script using the Window.open() method. If the window was not opened by a script, an error similar to this one appears in the console: Scripts may not close windows that were not opened by script.

So for closing window by close() function the window shouldn't has top-level context.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!