JavaScript element.requestFullscreen() Method

You are Here:

JavaScript element.requestFullscreen() Method

The element.requestFullscreen() method opens an element in fullscreen mode.

Note: It's not guaranteed that the element will be put into full screen mode. You can determine whether or not your attempt to switch to full-screen mode is successful by using the Promise returned by requestFullscreen().

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <video controls> <source src="/hawk.mp4" type="video/mp4"> </video> <p>Click on the button to request fullscreen of the video.</p> <button onclick="myFunction()">Click Me</button> <script> var elem = document.getElementsByTagName("video")[0]; function myFunction(){ elem.requestFullscreen().catch(err => { alert("Unable to display in fullscreen"); }); } </script> </body> </html>

Syntax

element.requestFullscreen()

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author