function f_SetFullScreen() {
//如果浏览器不是全屏则将其设置为全屏模式
if (!f_IsFullScreen()) {
var wsShell = new ActiveXObject('WScript.Shell')
wsShell.SendKeys('{F11}')
return false
}
}
//判断浏览器是否全屏
function f_IsFullScreen() {
return (document.body.scrollHeight == window.screen.height &&document.body.scrollWidth == window.screen.width)
}
document.addEventListener("fullscreenchange", function( event ) {if (document.fullscreenElement) {
console.log('进入全屏')
} else {
console.log('退出全屏')
}})
可以这样判断。但是旧版IE是不支持的。
<html><head>
<title>test</title>
<script language="JavaScript">
function Fkey(){
var WsShell = new ActiveXObject('WScript.Shell')
WsShell.SendKeys('{F11}')
}
</script>
</head>
<body>
<a href="javascript:Fkey()">屏幕切换</a>
</body>
</html>