本文介绍了ExitFullScreen不工作+无论如何键盘按下按钮点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的浏览器:Google Chrome版本33.0.1750.154 m
脚本:
function exitFullscreen(){
var element = document.documentElement;
if(element.mozCancelFullScreen){
element.mozCancelFullScreen();
} else if(element.webkitExitFullScreen){
element.webkitExitFullScreen();
} else if(elem.exitFullScreen){
element.exitFullScreen();
} else if(elem.msExitFullScreen){
element.msExitFullScreen();
$ / code $ / pre
$ b HTML:
< div class =menubuttonstyle =width:100px;的onclick = exitFullscreen(); >
< span class =menubuttontext> EXIT FULLSCREEN< / span>
< / div>
但是当我在fullscren模式下按下div时,什么也没有发生,我做了一个错字,写下了代码完全错误还是不可能?
备用Soultion?如果那个div按钮onclick可以触发一个键盘按下转义键,它也可以退出全屏,或者这是不可能的?
解决方案有是一个错字(尽管它不会解决问题)。
} else if(elem.exitFullScreen){// should元素
element.exitFullScreen();
} else if(elem.msExitFullScreen){
element.msExitFullScreen();
但是 exitFullscreen
应该在文档
对象上调用
function exitFullscreen(){
if(document.exitFullscreen){
document.exitFullscreen();
} else if(document.mozCancelFullScreen){
document.mozCancelFullScreen();
} else if(document.webkitExitFullscreen){
document.webkitExitFullscreen();
}
}
My Browser: Google Chrome Version 33.0.1750.154 m
Script:
function exitFullscreen() {
var element = document.documentElement;
if (element.mozCancelFullScreen) {
element.mozCancelFullScreen();
} else if (element.webkitExitFullScreen) {
element.webkitExitFullScreen();
} else if (elem.exitFullScreen) {
element.exitFullScreen();
} else if (elem.msExitFullScreen) {
element.msExitFullScreen();
}
}
HTML:
<div class="menubutton" style="width: 100px;" onclick="exitFullscreen();">
<span class="menubuttontext">EXIT FULLSCREEN</span>
</div>
but when I press that div in fullscren mode nothing happens, did I do a typo, wrote the code totally wrong or is it not possible?
Alternate Soultion? If that div button onclick can trigger a keyboard press escape key it can exit fullscreen too, or is this not possible?
解决方案 There is a typo in (though it won't solve the issue)
} else if (elem.exitFullScreen) { // should be element
element.exitFullScreen();
} else if (elem.msExitFullScreen) {
element.msExitFullScreen();
}
But the exitFullscreen
should be called on document
object only
function exitFullscreen() {
if(document.exitFullscreen) {
document.exitFullscreen();
} else if(document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if(document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
这篇关于ExitFullScreen不工作+无论如何键盘按下按钮点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!