嗨我有一个网页,我想从现有页面打开div元素(带有ID)及其内容到全屏。它在FF和Chrome中运行良好,但在IE10或IE11中无效。控制台日志中没有错误。在全屏幕中HTML5打开(页面元素)在Internet Explorer中HTML5失败
我用了一个类似的方法来找到这个在线例子,我发现在IE中它也不适合我:http://davidwalsh.name/demo/fullscreen.php。在IE中是否需要启用全屏显示设置? F11适合我。我认为可能有安全设置?
我使用的代码作为MS自己的文档中定义: http://msdn.microsoft.com/en-us/library/ie/dn254939(v=vs.85).aspx
function requestFullScreen(element) {
// Supports most browsers and their versions.
var requestMethod = element.requestFullScreen ||
element.webkitRequestFullScreen ||
element.mozRequestFullScreen ||
element.msRequestFullScreen;
console.log("element.msRequestFullScreen" + element.msRequestFullScreen);
if (requestMethod) { // Native full screen.
requestMethod.call(element);
} else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
}
}
}
$(".fullscreen").live('click',function(event) {
var elem = document.getElementById("fulltextview"); // Make the fulltext
view elements contents go full screen.
requestFullScreen(elem);
});
在这个例子中变量requestMethod总是未定义。
是否因为IE没有检测到onclick事件,并因此因安全问题而阻止请求?需要更多的帮助。 (是的,我不得不使用旧版本的jQuery 1.4.4)
一个例子,其中它不能正常工作(对我来说)是当有单击处理和msRequestFullscreen通话之间警报 – andreas