HTML5 JS Implementation Browser fullscreen

Source: Internet
Author: User

Fullscreen

var Docelm = document.documentelement;

W3c

if (Docelm.requestfullscreen) {

Docelm.requestfullscreen ();

}

FireFox

else if (Docelm.mozrequestfullscreen) {

Docelm.mozrequestfullscreen ();

}

Chrome and more

else if (Docelm.webkitrequestfullscreen) {

Docelm.webkitrequestfullscreen ();

}

IE11

else if (Elem.msrequestfullscreen) {

Elem.msrequestfullscreen ();

}

Exit Full Screen

if (Document.exitfullscreen) {

Document.exitfullscreen ();

}

else if (Document.mozcancelfullscreen) {

Document.mozcancelfullscreen ();

}

else if (Document.webkitcancelfullscreen) {

Document.webkitcancelfullscreen ();

}

else if (Document.m**itfullscreen) {

Document.m**itfullscreen ();

}

Event Monitoring

Document.addeventlistener ("Fullscreenchange", function () {

fullscreenstate.innerhtml = (document.fullscreen)? "": "Not";}, False);

Document.addeventlistener ("Mozfullscreenchange", function () {

fullscreenstate.innerhtml = (document.mozfullscreen)? "": "Not";}, False);

Document.addeventlistener ("Webkitfullscreenchange", function () {

fullscreenstate.innerhtml = (document.webkitisfullscreen)? "": "Not";}, False);

Document.addeventlistener ("Msfullscreenchange", function () {

fullscreenstate.innerhtml = (document.msfullscreenelement)? "": "Not";}, False);

Full screen style settings in the browser full screen use We can also make style settings

Html:-moz-full-screen {

background:red;

}

Html:-webkit-full-screen {

background:red;

}

Html:fullscreen {

background:red;

}

HTML5 JS Implementation Browser fullscreen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.