locked
Open the application in Fullscreen Mode RRS feed

  • Question

  • User-2055169795 posted

    Is there any way to always open the asp.net web application in Fullscreen mode whenever we run that application?

    Friday, September 28, 2018 5:41 AM

All replies

  • User283571144 posted

    Hi ashwin.barfa,

    Is there any way to always open the asp.net web application in Fullscreen mode whenever we run that application?

    As far as I know, we couldn't run the javascript to set the application to full screen, since the browser security issue.

    We could only set the full screen when user click the button.

    More details, you could refer to below codes:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FullScreenTest.aspx.cs" Inherits="AspNetNormalIssue.FullScreenTest" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style>
            html, body {
                background: white;
                padding: 0;
                margin: 0;
            }
    
            *:fullscreen
            *:-ms-fullscreen,
            *:-webkit-full-screen,
            *:-moz-full-screen {
                overflow: auto !important;
            }
        </style>
        <script>
             function toggleFullScreen(elem) {
                if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
                    if (elem.requestFullScreen) {
                        elem.requestFullScreen();
                    } else if (elem.mozRequestFullScreen) {
                        elem.mozRequestFullScreen();
                    } else if (elem.webkitRequestFullScreen) {
                        elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
                    } else if (elem.msRequestFullscreen) {
                        elem.msRequestFullscreen();
                    }
                } else {
                    if (document.cancelFullScreen) {
                        document.cancelFullScreen();
                    } else if (document.mozCancelFullScreen) {
                        document.mozCancelFullScreen();
                    } else if (document.webkitCancelFullScreen) {
                        document.webkitCancelFullScreen();
                    } else if (document.msExitFullscreen) {
                        document.msExitFullscreen();
                    }
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <p id="text">
                    Click the below to toggle full screen
                </p>
                <input type="button" value="click to toggle fullscreen on the body" onclick="toggleFullScreen(document.body)" />
                <input type="button" value="click to toggle fullscreen on the text" onclick="toggleFullScreen(document.getElementById('text'))" />
            </div>
        </form>
    
    </body>
    </html>
    

    Result:

    Best Regards,

    Brando

    Monday, October 1, 2018 2:45 AM