July 18, 2016

How to view web site in fullscreen using HTML5 and jQuery?


Please follow below step and refer this link for more help.

1: First include following two JS in header part between <head> tab,

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script src="//use.fontawesome.com/aa03aaad2f.js"></script>

2: HTML code for just link

<a href="javascript:;" class="fullscreen "><i class="fa fa-arrows-alt"></i> View Fullscreen</a>
 

3: jQuery API code
 
$(".fullscreen-toggle").on("click", function() {
    document.fullScreenElement && null !== document.fullScreenElement ||
    !document.mozFullScreen && !document.webkitIsFullScreen ?
    document.documentElement.requestFullScreen ?
    document.documentElement.requestFullScreen() :
    document.documentElement.mozRequestFullScreen ?
    document.documentElement.mozRequestFullScreen() :
    document.documentElement.webkitRequestFullScreen &&
    document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):
    document.cancelFullScreen ? document.cancelFullScreen() :
    document.mozCancelFullScreen ? document.mozCancelFullScreen() :
    document.webkitCancelFullScreen && document.webkitCancelFullScreen()
});
 
For more details click Here!

Demo

Enjoy!



No comments:

Post a Comment

Integrating Google reCAPTCHA v3 in HTML Form with PHP

  What is Google reCAPTCHA v3? Google reCAPTCHA is a free service that helps protect websites from spam and abuse. reCAPTCHA v3 is the lates...