前端实现全屏功能
2019-07-25 本文已影响0人
黏人的胶粒子
function openBig () {
# 想要全屏展示的模块包含class名content
var elem = document.querySelector('.content');
requestFullScreen(elem);
};
function requestFullScreen (elem) {
#兼容不同的浏览器
var requestMethod = elem.requestFullScreen || elem.webkitRequestFullScreen || elem.mozRequestFullScreen || elem.msRequestFullScreen;
if (requestMethod) {
requestMethod.call(elem)
} else if (typeof window.ActiveXObject !== 'undefined') {
#模拟F11 实现全屏
var wscript = new ActiveXObject('WScript.Shell')
if (wscript !== null) {
wscript.SendKeys('{F11}')
}
}
}