使用jq关闭网页时,谷歌/火狐不允许直接关闭,所以不能直接使用window.close();
对关闭方法进行改造
var userAgent = navigator.userAgent;
if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") != -1) {
location.href = "about:blank";
} else {
window.opener = null;
window.open('', '_self');
}
window.close();
使用上述代码,通过连接打开的页面可以关闭,
但是直接在地址栏上写的或者window.location.href跳转的页面还是不能关闭。