Function to open the full screen (Fullscreen) No angle 2 [duplicate]

0

I need to have my screen open full ... When I give a ng Serve for the application when running it comes with a fullscreen. Can anyone give me a hint how to do this?

    
asked by anonymous 22.05.2018 / 19:56

1 answer

-1

Create this function:

function requestFullScreen(element) {
    // Supports most browsers and their versions.
    var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;

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

and add your call, passing the body element as a parameter to an event that the user can interact with.

For example, in the click of a button with the phrase "Click here to Maximize" or in the body click (example only):

<!DOCTYPE html>
<html>
<head>
    <title>teste</title>
    <script type="text/javascript">
        function requestFullScreen(element) {
            // Supports most browsers and their versions.
            var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;

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

        window.onload = function(){
            function setarFullScreen(){
                var elem = document.body;
                requestFullScreen(elem);
                document.getElementById("click").style.display = "none";    
            }
            document.getElementById("click").addEventListener("click", setarFullScreen);
        };
    </script>
</head>
<body>
    <button id="click">Clique aqui para maximizar</button>
    <div style="color: red;">teste</div>
</body>
</html>

Note: As a rule, the user must first accept the request in full screen, and it can not be triggered automatically in pageload, it must be triggered by a user (as in this example, by a button) p>     

23.05.2018 / 00:39