首页 > 代码库 > js关闭当前页面

js关闭当前页面

$(".close-btn").on("click", function () {
        var userAgent = navigator.userAgent;
        if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") != -1) {
            window.open("", "_self").close();
        } else {
            window.opener = null;
            window.open("", "_self");
            window.close();
        }
    });

 

js关闭当前页面