Using HTML5's FullScreen API
Join the DZone community and get the full member experience.Join For Free
I've been looking into ways in which a web application can be made more user friendly and HTML5 does include some powerful features such as PageVisibility, Navigation Timing, etc,. that can be used to provide good user experience. Today I was looking into FullScreen API that allows you show any of the elements in the DOM in Full-Screen mode. Suppose you have a HTML5 video embedded in a page and would like to play that video in full-screen mode then it is now possible with the FullScreen API. Similarly say if you have an image element, it can also be shown in full screen mode.
To present a element in the full-screen mode you have to call the method requestFullScreen() on that element. I've created a demo that shows a picture and when you click on a button it shows it in the full-screen mode and then changes the picture every three seconds creating a slideshow like experience.
To exit from the full-screen mode you can press the 'Esc' key. In the changePicture method I'm checking whether the full-screen mode is still activated by referring to the variable webkitIsFullScreen defined in the document object. It returns true if full-screen mode is activated and false otherwise.
Published at DZone with permission of Sagar Ganatra, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.