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

2.6K
Views
Close browser tab (window) in angular

I there any trick that I can use to close browser tab (window) in angular. most of methods I tried are not working. the error I got is "scripts may close only the windows that were opened by them". help to ignore this

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

0

The Window interface represents a window containing a DOM document; the document property points to the DOM document loaded in that window.

A global variable, window, representing the window in which the script is running, is exposed to JavaScript code.

Where the window.parent property returns the immediate parent of the current window, window.top returns the topmost window in the hierarchy of window objects.

You can simply use the following code:

window.top.close();

The Window self() property is used for returning the current window. It is generally used for comparison purposes while using other functions such as top().

You can simply use the following code:

window.self.close(); 

Warning!

Sometimes you can't close the current window in Firefox because you didn't open it. Most people have their browser set to open new windows in a new tab, and you can't prevent the menu bar etc in a tab window.

If you use close() method, 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.

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!