我在MVC代码中应用了一个jquery函数,用于在单击按钮时以全屏模式显示当前窗口。这是它的jquery:
function FullScreen() {
if ((document.fullScreenElement && document.fullScreenElement !== null) || // alternative standard method
(!document.mozFullScreen && !document.webkitIsFullScreen)) { // current working methods
if (document.documentElement.requestFullScreen) {
document.documentElement.requestFullScreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullScreen) {
document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}
}我已经在标签的onclick事件上调用了这个函数。有了这个,我就可以在Chrome和Mozilla上打开我的窗口按钮,在全屏模式下点击,也可以在按ESC键的时候退出全屏模式。但在IE8中,当我单击该按钮时,什么也没有发生。我怎样才能让这个函数在IE8上工作。有什么建议吗?
谢谢。
发布于 2012-11-19 20:25:14
如果浏览器支持全屏应用编程接口(Chrome,FX10,Safari6,Opera12.1),那么你可以使用它。
如果不是这样(例如IE8),那么出于安全原因,您不应该能够模仿它:如果我可以创建一个全屏运行的页面,而不需要事先通知用户,那么我就可以模仿要求输入密码等的OS界面元素。
这是how a phishing scam might work的一个很好的例子。
此安全原因就是WebKit实现禁用键盘输入的原因。
IE过去支持无铬弹出窗口,但这是removed as a security bug in IE6。
例如,您可以尝试发送F11密钥:
var shell = new ActiveXObject("WScript.Shell");
shell.SendKeys("{F11}");但这不应该在互联网环境中被允许(它可能在受信任的域中,取决于用户设置)。
无论如何,IE10都是全屏运行(默认情况下),所以仍然不支持这个接口。
发布于 2012-05-26 05:50:05
对不起,IE8目前还不支持全屏接口。Here是一篇关于使用全屏应用编程接口的好文章。它还指出Internet Explorer不支持全屏API。
在in或Opera中还不支持,但我建议你在以后的校对中使用‘ms’和‘o’前缀。
https://stackoverflow.com/questions/10759483
复制相似问题