ASP. NET MVC; Javascript; HTML: Как сделать собственную кнопку, закрывающую браузер? - PullRequest
0 голосов
/ 24 февраля 2020

Как сделать кнопку, закрывающую браузер? Приведенный ниже код не работает для моего ASP. NET MVC приложения. Я уже тестировал его на Mozilla, Chrome и Edge.

<!DOCTYPE html>
<body>
    <input type="submit" id="btnCloseScreen" name="btnCloseScreen" value="X" style="font-size:large; font-weight:bold; background-color:red; width:30px; border-color:#3f464c; height:30px" />
</body>

    $("#btnCloseScreen").click(function () {

        var Browser = navigator.appName;
        var indexB = Browser.indexOf('Explorer');

        if (indexB > 0) {
            var indexV = navigator.userAgent.indexOf('MSIE') + 5;
            var Version = navigator.userAgent.substring(indexV, indexV + 1);

            if (Version >= 7) {
                window.open('', '_self', '');
                window.close();
            }
            else if (Version == 6) {
                window.opener = null;
                window.close();
            }
            else {
                window.opener = '';
                window.close();
            }
        }
        else {
            window.open('', '_self', ''); window.close();
        }
    }
    </script>

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...