Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!