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>