用JavaScript模拟F11 [英] Simulate F11 with javascript
本文介绍了用JavaScript模拟F11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能像Flash一样模拟 F11 (全屏不是最大化浏览器窗口):
http://www.broculos.net/files/articles/FullscreenFlash/flashFullscreen.html ?
in flash: fscommand(fullscreen,true)
permadi / b
$ b 更新
我发现这个:
var docElm = document.documentElement;
if(docElm.requestFullscreen){
docElm.requestFullscreen();
} else if(docElm.mozRequestFullScreen){
docElm.mozRequestFullScreen();
} else if(docElm.webkitRequestFullScreen){
docElm.webkitRequestFullScreen();
}
/ *退出全屏=>显示FULL SCREEN按钮* /
if(docElm.requestFullscreen){
document.addEventListener(fullscreenchange,function(){
if(!document.fullscreen){
//做点什么
}
},false);
} else if(docElm.mozRequestFullScreen){
document.addEventListener(mozfullscreenchange,function(){
if(!document.mozFullScreen){
//做某事
}
},false);
} else if(docElm.webkitRequestFullScreen){
document.addEventListener(webkitfullscreenchange,function(){
if(!document.webkitIsFullScreen){
//做某事
}
},false);
}
只有在点击按钮时才有效。在页面加载时无法做到这一点。 解决方案
这对于JavaScript来说是不可能的。它被提议用于HTML5视频API,但之后被报废< a>。
How can I simulate F11 (fullscreen not maximaze browser window) as with flash: http://www.broculos.net/files/articles/FullscreenFlash/flashFullscreen.html ?
in flash: fscommand("fullscreen", true )
permadi.com/tutorial/flash9FullScreen/index.html
Thanks
Update
I found this:
var docElm = document.documentElement;
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
} else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
} else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
}
/* Exiting the full screen => showing the FULL SCREEN button */
if (docElm.requestFullscreen) {
document.addEventListener("fullscreenchange", function () {
if(!document.fullscreen) {
// Do something
}
}, false);
} else if (docElm.mozRequestFullScreen) {
document.addEventListener("mozfullscreenchange", function () {
if(!document.mozFullScreen) {
// Do something
}
}, false);
} else if (docElm.webkitRequestFullScreen) {
document.addEventListener("webkitfullscreenchange", function () {
if(!document.webkitIsFullScreen) {
// Do something
}
}, false);
}
this only works (from what've seen) only on a button click. Can't do this on page load
解决方案
This isn't possible with JavaScript. It was proposed for the HTML5 video API but was later scrapped.
这篇关于用JavaScript模拟F11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文