在页面加载时禁用 window 任务栏 asp.net c#

disable window task bar on page load asp.net c#

我正在开发一个应用程序,用户要求在 asp.net 页面加载后禁用 window taskbaar。我正在使用 asp.net 和 c#。

请帮帮我

您可以使用下面的 javascript 函数完成此任务。

<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> 
  • 将上面的代码放在 .aspx 页面的 <head> 标签中。

你可以使用 HTML5 API 全屏模式 Click here

更新答案 如果以上代码不起作用,请尝试使用以下代码强制执行“F11”键事件。

function requestFullScreen(element) {

    var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullscreen;

    if (requestMethod) { 
        requestMethod.call(element);
    } else if (typeof window.ActiveXObject !== "undefined") { 
        var wscript = new ActiveXObject("WScript.Shell");
        if (wscript !== null) {
            wscript.SendKeys("{F11}");
        }
    }
}

var elem = document.body; 
requestFullScreen(elem);