我們在js中判斷能力窗口或頁面都離不開window.close()函數(shù)了,但是如果要做到兼容所有瀏覽器實現(xiàn)關閉當前窗口話并不是直接使用window.close()即可解決了。
可兼容所有瀏覽器關閉當前頁面函數(shù):
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();
}
}