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

161
Vistas
how would I catch a JavaScript warning in a try / catch statement?

I need to be able to check if I can close the current page, however since it returns the warning "Scripts may close only the windows that were opened by them." It wont be caught by a try/catch statement because it isn't an "error". Is there any way I can get around this?

function attemptToClose() {
  try {
     window.close();
  }
  catch(err) {
    //do something different
    console.log(err)
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If I understand this correctly window.close(); can only close pages open by itself aka window.open();. This might be a security prevention method so that websites do not take control of your browsers.

Try initiating the page with window.open(); then try using the window.close();.

Hope this solves it!

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