馒头bun

js关闭当前页面

参考文章(https://www.cnblogs.com/ygunoil/p/12893152.html)

直接上代码

1.JS代码

       function closewin() {
            if (navigator.userAgent.indexOf('MSIE') > 0) { // close IE
                if (navigator.userAgent.indexOf('MSIE 6.0') > 0) {
                    window.opener = null;
                    window.close();
                } else {
                    window.open('', '_top');
                    window.top.close();
                }
            } else { // close chrome;It is effective when it is only one.
                window.opener = null;
                window.open('', '_self');
                window.close();
            }
        }

2.HTML代码

<a onclick="closewin()" >关闭</a>

posted on 2021-01-18 15:41  馒头bun  阅读(173)  评论(1编辑  收藏  举报

导航