Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

2.6K
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda