Asp. Net MVC как сделать собственную кнопку закрытия и полноэкранного режима? - PullRequest
2 голосов
/ 21 февраля 2020

Я очень плохо знаком с ASP. NET MVC и веб-разработкой, и я не знаю, как реализовать полноэкранный режим и кнопку выхода

Это моя кнопка выхода до сих пор :

<body>
<div id="exit" class="exit">
    @Html.ActionLink("⠀x⠀", null, null, new { @class = "btnclose", id = "close", style = "color: black; font-size:large; font-weight:bold; background-color:red; border-color:#3f464c; border:solid; border-width: 2px" })
</div>
</body>
<script>
    function closewindow() {
        $("#close").click(function () {
            window.close();
        });
    };
</script>

и это моя полноэкранная кнопка

<body>
<div align="center">
            <input type="button" name="btnFullscreen" value="Go Fullscreen" style="font-size:xx-large; font-weight:bold; width:500px; height:300px; text-align:center; background-color:#e87a3a; border-color:#3f464c" onclick="goFullscreen()" />
</div>
<body>

<script>

function goFullscreen() {
        location.replace("/Gauge/GaugeView");
        var el = document.documentElement
            , rfs = // for newer Webkit and Firefox
                el.requestFullscreen
                || el.webkitRequestFullScreen
                || el.mozRequestFullScreen
                || el.msRequestFullscreen
            ;
        if (typeof rfs != "undefined" && rfs) {
            rfs.call(el);
        } else if (typeof window.ActiveXObject != "undefined") {
            // for Internet Explorer
            var wscript = new ActiveXObject("WScript.Shell");
            if (wscript != null) {
                wscript.SendKeys("{F11}");
            }
        }
    }

1 Ответ

1 голос
/ 21 февраля 2020

Привет! Я пересмотрел твой код, ты почти был там. Но в вашем коде осталось немного проблем.

Вот полный пример для вас.

<!DOCTYPE html>
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <div>
        <input type="submit" id="btnFullScreen" name="btnFullScreen" value="Full Screen" />
        <input type="submit" id="btnCloseScreen" name="btnCloseScreen" value="Close Full Screen" />
    </div>
    <script type="text/javascript">


    </script>

    <script type="text/javascript">

        //Btn Full Screen
        $("#btnFullScreen").click(function () {
            alert("Test");
            var el = document.documentElement,
                rfs = el.requestFullscreen
                    || el.webkitRequestFullScreen
                    || el.mozRequestFullScreen
                    || el.msRequestFullscreen
                ;

            rfs.call(el);
        });

        //Btn Close Screen
        $("#btnCloseScreen").click(function () {

            alert("Close Screen");
            if (document.exitFullscreen) {
                document.exitFullscreen();
            } else if (document.mozCancelFullScreen) {
                document.mozCancelFullScreen();
            } else if (document.webkitExitFullscreen) {
                document.webkitExitFullscreen();
            } else if (document.msExitFullscreen) {
                document.msExitFullscreen();
            }

        });
    </script>
</body>
</html>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...