有没有办法在没有任何用户交互的情况下在ASP.Net MVC中全屏打开我的Web应用程序

时间:2017-01-27 04:46:56

标签: javascript jquery asp.net-mvc

有没有办法在没有任何用户交互的情况下在ASP.Net MVC中全屏打开我的Web应用程序(如同按F11)。

我使用的是以下代码,但这不适用于页面加载时间,这在页面中的用户操作时有效。 但是我需要在加载页面时全屏打开我的网页。

下面的代码正在处理点击事件,但不适用于页面加载。

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Demo</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <style>
        html:-moz-full-screen {
            background: red;
        }

        html:-webkit-full-screen {
            background: red;
        }

        html:-ms-fullscreen {
            background: red;
            width: 100%;
        }

        html:fullscreen {
            background: red;
        }
    </style>
</head>
<body style="background:white;">
    <button id="btn">Fullscreen</button>
    <div id="test" style="width:512px; height:100px; background-color:#000000;" >
        <span>this is test</span>
    </div>
    <script>
        $(document).ready(function () {
            var canvas = document.getElementById('test');
            fullScreen(canvas);
        });

        function fullScreen(element) {
            if (element.requestFullScreen) {
                console.log("1");
                element.requestFullScreen();
            } else if (element.webkitRequestFullScreen) {
                console.log("2");
                element.webkitRequestFullScreen();
            } else if (element.mozRequestFullScreen) {
                console.log("3");
                element.mozRequestFullScreen();

            }
        }

    </script>
</body>

</html>

请建议我们该怎么做?

0 个答案:

没有答案