<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>quanping</title>
</head>
<body>
<div id="div" onclick="fullScreen()">全屏</div>
<div onclick="exitFull()">退出全屏</div>
<script type="text/javascript">
function fullScreen(){
var el = document.documentElement;
var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen;
if(typeof rfs != "undefined" && rfs) {
rfs.call(el);
};
return;
}
function exitFull() {
var exitMethod = document.exitFullscreen ||
document.mozCancelFullScreen ||
document.webkitExitFullscreen ||
document.msExitFullscreen;
if (exitMethod) {
exitMethod.call(document);
}
else if (typeof window.ActiveXObject !== "undefined") {//for Internet Explorer
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
}
}
}
document.getElementById('div').click();
</script>
</body>
</html>
本示例可实现点击全屏效果,但是这个API接口不能实现,页面加载完成就执行全屏的效果