Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Fullscreen API

According to this article Google Chrome 15 has a fullscreen JavaScript API.

I have tried to make it work but failed. I have also searched for official documentation in vain.

What does the fullscreen JavaScript API look like?

like image 988
Randomblue Avatar asked Oct 20 '11 12:10

Randomblue


People also ask

What is fullscreen API?

The Fullscreen API adds methods to present a specific Element (and its descendants) in fullscreen mode, and to exit fullscreen mode once it is no longer needed.

How do I force Chrome full screen?

To go full screen on Google Chrome, click the full screen mode icon in its hamburger menu. You can also enter full screen by pressing "F11" on PC or "Control + Command + F" on Mac. Mac users can also press the "expand window" button to enter or exit full screen in Chrome.

How do I make Chrome full screen instead of F11?

The quickest way to get Chrome in full-screen mode in Windows is to press F11 on the keyboard. The other way is through the Chrome menu: In the upper-right corner of Chrome, select the menu (three-dot) icon. In the Zoom section, select the square icon on the right.

How do I make Javascript full screen in Chrome?

Full-screen can be activated for the whole browser window by pressing the F11 key. It can be exited by pressing the Esc button. It is also possible to make a specific element in the page to enter and exit full-screen mode programmatically using Javascript Fullscreen API.


2 Answers

The API only works during user interaction, so it cannot be used maliciously. Try the following code:

addEventListener("click", function() {     var el = document.documentElement,       rfs = el.requestFullscreen         || el.webkitRequestFullScreen         || el.mozRequestFullScreen         || el.msRequestFullscreen      ;      rfs.call(el); }); 
like image 88
Eli Grey Avatar answered Oct 10 '22 12:10

Eli Grey


I made a simple wrapper for the Fullscreen API, called screenfull.js, to smooth out the prefix mess and fix some inconsistencies in the different implementations. Check out the demo to see how the Fullscreen API works.

Recommended reading:

  • Using the Fullscreen API in web browsers
  • MDN - Fullscreen API
like image 40
Sindre Sorhus Avatar answered Oct 10 '22 13:10

Sindre Sorhus