關閉當前頁面
function closeWindow(){
var userAgent = navigator.userAgent;
if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") !=-1) {
window.location.href="about:blank";
window.close();
} else {
window.opener = null;
window.open("", "_self");
window.close();
}
}
或者直接這樣寫(ie中測試也可以關閉):
window.open("about:blank","_self").close()
在問題在於當在vue+chrome中使用時,有些chrome版本智能跳轉到about:blank空頁面中,無法關閉當前頁面,目前沒有找到解決辦法,頭疼中...