我试图将浏览器自动设置为全屏模式。
这是我的jQuery代码。
function ActivateFullScreen() {
var docElm = document.documentElement;
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
} else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
} else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
}
}
//将onlick事件绑定到我的按钮
$('#triggerFullscreen').click(function () {
ActivateFullScreen();
});
//这些都不起作用。
$('#triggerFullscreen').click();
$('#triggerFullscreen').trigger('click');
ActivateFullScreen();
//我的按钮
<button id="triggerFullscreen" ></button>
如果我手动按下按钮,我的浏览器将设置为全屏模式。我真的不知道为什么这行不通。
战车和最诚挚的问候
马库斯
是的,似乎是安全限制
"To prevent embedded content from going fullscreen only embedded content specifically allowed via the allowfullscreen attribute of the HTML iframe element will be able to go fullscreen. This prevents untrusted content from going fullscreen."
全文请访问https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句