浏览器兼容JS关闭页签方法
方法1
function closePage(){
var browserName = navigator.appName;
if (browserName == "Netscape") {
window.location.href = "about:blank"; //关键是这句话
window.close();
} else if (browserName == "Microsoft Internet Explorer") {
window.opener = null;
window.close();
}
}
方法2
function CloseWebPage(){
if (navigator.userAgent.indexOf("MSIE") > 0) {
if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
window.opener = null;
window.close();
} else {
window.open('', '_top');
window.top.close();
}
}else if (navigator.userAgent.indexOf("Firefox") > 0) {
window.location.href = 'about:blank ';
}else {
/*
window.opener = null;
window.open('', '_self', '');
window.close();
*/
$(document.body).hide();
window.document.title="";
// window.location.href = 'about:blank ';
window.history.back();
window.close();
}
}