移动端关闭当前窗口/关闭当前页面

转发自:http://www.cnblogs.com/htmlcssjs/p/4569914.html

var userAgent = navigator.userAgent;
if (userAgent.indexOf(“Firefox”) != -1 || userAgent.indexOf(“Chrome”) !=-1) {
window.location.href=”about:blank”;
}else if(userAgent.indexOf(‘Android’) > -1 || userAgent.indexOf(‘Linux’) > -1){
window.opener=null;window.open(‘about:blank’,’_self’,”).close();
}else {
window.opener = null;
window.open(“about:blank”, “_self”);
window.close();
}
希望对大家有帮助!

你可能感兴趣的:(web前端)