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

327
Vistas
Is it possible to stop javascript from knowing if window/document has focus?

Some websites stop working (for example, playing music) if one moves from one tab to another. Question: Is it possible for the client to stop this behaviour?

There are multiple ways to check if the current browser tab is focused. One can use document.hasFocus() or window.addEventListener('focus', function), for example. The visibilitychange or blur events aren't cancelable, so Event.stopPropagation wouldn't work. But is there any other way to stop their propagation? (For example, could an addon break the way the blur event works and not make it dispatch?)

Or is there a way to simulate a tab having focus via the JS console? For example, by toggling a checkbox in the Web Console or by constantly retriggering a focus event after the tab loses focus? (Or maybe could tampermonkey force set the read-only document.visibilityState always to visible?)


Regarding the question being closed: This question is not the same as Is there a way to detect if a browser window is not currently active?, it's asking from the opposite direction: that question asks how can one detect changes in focus, this one asks how can one avoid that detection

about 4 years ago · Juan Pablo Isaza
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