使用JavaScript在浏览器中触发全屏 [英] Triggering full screen in browser with JavaScript

查看:96
本文介绍了使用JavaScript在浏览器中触发全屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何使Javascript完整屏幕窗口(遍及整个屏幕)

Possible Duplicate:
How to make in Javascript full screen windows (stretching all over the screen)

当前,我尝试做类似的事情,当您单击全屏按钮时,当前窗口将变为全屏.我尝试使用以下脚本,但是它不起作用.关于如何进行这项工作的任何想法?

Currently I tried to do something like, when you click a fullscreen button current window will become full screen. I tried to use the following script, but it doesn't work. Any ideas on how to make this work?

<script type="text/javascript">
window.onload = maxWindow;

function maxWindow() {
    window.moveTo(0, 0);

    if (document.all) {
        top.window.resizeTo(screen.availWidth, screen.availHeight);
    }
    else if (document.layers || document.getElementById) {
        if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth) {
            top.window.outerHeight = screen.availHeight;
            top.window.outerWidth = screen.availWidth;
        }
    }
}
</script>

推荐答案

某些较新的浏览器支持一个新的API,可让您将任何元素都放在整个屏幕上:

There's a new API supported by some of the newer browsers that'll let you make any element take over the whole screen:

请参见 http://johndyer.name/native-fullscreen- javascript-api-plus-jquery-plugin/了解更多信息,包括使用该功能的jQuery插件.

See http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/ for more info, including a jQuery plugin to use the feature.

这篇关于使用JavaScript在浏览器中触发全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆