Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

2.6K
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda