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

135
Vistas
Re-enter fullscreen mode after a JavaScript alert call

I have this web page that is already in fullscreen mode. Now, when testing with Google Chrome, if I make a call to the alert function, the page would quit fullscreen mode.

While I understand that this might be standard behavior, I would still like to make the page re-enter fullscreen mode after quitting it. I now have this function:

function enterFullScreen() {
    let element = document.documentElement;
    if (element.requestFullscreen) {
        element.requestFullscreen();
    }
    else if (element["mozRequestFullScreen"]) {
        element["mozRequestFullScreen"]();
    }
    else if (element["webkitRequestFullscreen"]) {
        element["webkitRequestFullscreen"]();
    }
    else if (element["msRequestFullscreen"]) {
        element["msRequestFullscreen"]();
    }
}

It works fine when I run it directly in the console, but when I put it after the alert call, believing it would make the page re-enter fullscreen mode, it ceases to work:

elem.onclick = function () {
    alert("something");
    enterFullScreen(); // Nothing happens what-so-ever. No errors either.
}

What might be the problem to this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The alert probably wasn't fully closed when you re-requested fullscreen. You can simply solve this by setting a timeout without a timeout:

alert("something");
setTimeout(enterFullScreen);
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