2

以下是脚本

 <script type="text/javascript">
            function DoFullScreen() {

                var isInFullScreen = (document.fullScreenElement && document.fullScreenElement !== null) ||    // alternative standard method  
                (document.mozFullScreen || document.webkitIsFullScreen);

                var docElm = document.documentElement;
                if (!isInFullScreen) {

                    if (docElm.requestFullscreen) {
                        docElm.requestFullscreen();
                    }
                    else if (docElm.mozRequestFullScreen) {
                        docElm.mozRequestFullScreen();
                        //alert("Mozilla entering fullscreen!");
                    }
                    else if (docElm.webkitRequestFullScreen) {
                        docElm.webkitRequestFullScreen();
                        alert("Webkit entering fullscreen!");
                    }
                }
            }

        </script>

HTML

<body onload="DoFullScreen()">
    <form id="form1" runat="server" >
        <div id="div1">
            <input id="bt1" type="button" value="button"   />
            Hello
        </div>
    </form>
</body>

我努力了

  1. $(window).load
  2. $(document).ready(function(){ $("#bt1").load
4

3 回答 3

3

-- 如果不是由用户操作触发,则无法强制全屏

- 看这个

加载文档时的全屏浏览器窗口

于 2013-05-07T09:44:50.523 回答
0

javascript只能像这样使用 pure 来做到这一点:

<script type="text/javascript">
window.onload = function () {

                // YOUR CODE STUFF 

                }
</script>
于 2013-05-07T09:50:06.733 回答
0

准备好调用你的函数

$(文档).ready(函数(){

DoFullScreen();

}

于 2013-05-07T09:43:53.783 回答