requestFullscreen() method in javascript
requestFullscreen() method is used to display the whole document or a single html element in full screen mode.
It cannot be done automatically but can be done only using user action.
This method is browser dependent, so for each browser different method name should be used, they are
- Standard version - requestFullscreen
- chrome - webkitRequestFullscreen
- Firefox - mozRequestFullScreen
- Internet Explorer - msRequestFullscreen
Display particular element in full screen mode using javascript
Example Explanation
- When the button is clicked, fun_name function is called.
- In the function, we are getting the element using its id(document.getElementById("divID")) and storing it in a variable(targetelement).
- Next using if statement we are checking which command is supported in the current browser, and that method will be executed and the specified element(divID) is displayed in full screen mode.
Display whole window in full screen mode using javascript
Example Explanation
- When the button is clicked, fun_name function is called.
- In the function, we are getting the whole document (document.documentElement) and storing it in a variable(targetelement).
- Next using if statement we are checking which command is supported in the current browser, and that method will be executed and the whole window is displayed in full screen mode.