用javascript模拟F11

时间:2010-06-22 14:38:14

标签: javascript flash fullscreen

如何使用flash模拟 F11 (全屏不是最大化浏览器窗口): http://www.broculos.net/files/articles/FullscreenFlash/flashFullscreen.html

flash中的

fscommand("fullscreen", true )

permadi.com/tutorial/flash9FullScreen/index.html

由于

更新

我发现了这个:

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);
}

仅在点击按钮时起作用(来自所见)。在页面加载时无法执行此操作

2 个答案:

答案 0 :(得分:2)

使用JavaScript无法做到这一点。它是针对HTML5视频API提出的,但后来是scrapped

答案 1 :(得分:0)

Mozilla有一个非常基础的教程:

请注意,截至本文,这是“实验技术”。

function requestFullScreen(elt) {
    console.log("Requesting fullscreen for", elt);
    if (elt.requestFullscreen) {
        elt.requestFullscreen();
    } else if (elt.msRequestFullscreen) {
        elt.msRequestFullscreen();
    } else if (elt.mozRequestFullScreen) {
        elt.mozRequestFullScreen();
    } else if (elt.webkitRequestFullscreen) {
        elt.webkitRequestFullscreen();
    } else {
        console.error("Fullscreen not available");
    }
}

我能够使用div,video和canvas元素成功测试它。以下是jsfiddle中的代码 - http://jsfiddle.net/luken/001834wn/ - 但请注意由于某种原因它实际上不适用于jsfiddle