Switch browser to fullscreen mode with JavaScript
Question:
How to switch browser to fullscreen mode with JavaScript? Answer:
document.documentElement.requestFullscreen();
Description:
You can switch your browser to full-screen mode by pressing the F11
key on your keyboard. However, not all users know this keyboard shortcut so it can be helpful in some cases to put a dedicated button on your webpage that allows to user to switch to full screen mode.
Modern desktop browsers support the Fullscreen API that allows entering to and exit from full-screen mode.
Use requestFullscreen()
method on an element (and not on document) to put the element into fullscreen.
Reference:
requestFullscreen reference
Share "How to switch browser to fullscreen mode with JavaScript?"
Related snippets:
Tags:
browser, fullscreen, f11, requestFullscreen, API, javascript Technical term:
Switch browser to fullscreen mode with JavaScript