1. Fullscreen API

This API allows developers to programmatically run Web applications in full screen, making Web applications more like native applications.

// Find a full-screen method that works for the browserfunction launchFullScreen(element) {    if(element.requestFullScreen) {      element.requestFullScreen();    } else if(element.mozRequestFullScreen) {      element.mozRequestFullScreen();    } else if(element.webkitRequestFullScreen) { element.webkitRequestFullScreen(); } // Start launchFullScreen(document.documentElement); // the whole page launchFullScreen(document.getElementById("videoElement")); // any individual element  Copy the code


2. Page Visibility API

This API can be used to detect the visibility of a page to the user by returning state changes to the page or TAB that the user is currently viewing.

// Set the name of the hidden attribute and visible change event, // Since some Browsers only offer Vendor-prefixed support var hidden, state, visibilityChange;if(typeof document.hidden ! = ="undefined") {    hidden = "hidden";    visibilityChange = "visibilitychange";    state = "visibilityState";  } else if(typeof document.mozHidden ! = ="undefined") {    hidden = "mozHidden";    visibilityChange = "mozvisibilitychange";    state = "mozVisibilityState";  } else if(typeof document.msHidden ! = ="undefined") {    hidden = "msHidden";    visibilityChange = "msvisibilitychange";    state = "msVisibilityState";  } else if(typeof document.webkitHidden ! = ="undefined") {    hidden = "webkitHidden";    visibilityChange = "webkitvisibilitychange";    state = "webkitVisibilityState"; } / / add a title change listener document. The addEventListener (visibilityChange,function(e) {// Start or stop state processing},false);  Copy the code


3. getUserMedia API

The API allows Web applications to access the camera and microphone without the need for plug-ins.

// Set the event listener window.addeventListener ("DOMContentLoaded".functionVar canvas = document.getelementById () {var canvas = document.getelementById ();"canvas"),      context = canvas.getContext("2d"),      video = document.getElementById("video"),      videoObj = { "video": true },      errBack = function(error) {        console.log("Video capture error: ", error.code); }; // Set the video listenerif(navigator.getUserMedia) { // Standard      navigator.getUserMedia(videoObj, function(stream) {        video.src = stream;        video.play();      }, errBack);    } else if(navigator.webkitGetUserMedia) { // WebKit-prefixed      navigator.webkitGetUserMedia(videoObj, function(stream){ video.src = window.webkitURL.createObjectURL(stream); video.play(); }, errBack); }},false);  Copy the code


4. Battery API

This is an API for mobile device applications, mainly used to detect device battery information.

var battery = navigator.battery || navigator.webkitBattery || navigator.mozBattery; // Battery properties console.warn("Battery charging: ", battery.charging); // true  console.warn("Battery level: ", battery.level); / / 0.58 console. Warn ("Battery discharging time: ", battery.dischargingTime); // addEventListener battery.addEventListener("chargingchange".function(e) {    console.warn("Battery charge change: ", battery.charging);  }, false);  Copy the code


5. Link Prefetching

Preload web content to provide a smooth browsing experience for visitors.

<! -- full page --> <link rel="prefetch" href="http://davidwalsh.name/css-enhancements-user-experience"/ > <! -- just an image --> <link rel="prefetch" href="http://davidwalsh.name/wp-content/themes/walshbook3/images/sprite.png" />  Copy the code


This article is reprinted from: www.iteye.com/news/26489


For the page recording function, see www.jb51.net/article/162…