首页 > 其他 > 详细

根据history判断,有历史页就返回上一页,没有就关闭页面

时间:2020-02-20 17:17:59      阅读:130      评论:0      收藏:0      [点我收藏+]
//根据history判断,有历史页就返回上一页,没有就关闭页面
function
goBack(){ if ((navigator.userAgent.indexOf(‘MSIE‘) >= 0) && (navigator.userAgent.indexOf(‘Opera‘) < 0)){ // IE if(history.length > 0){ window.history.go( -1 ); }else{ window.close() } }else{ //非IE浏览器 if (navigator.userAgent.indexOf(‘Firefox‘) >= 0 || navigator.userAgent.indexOf(‘Opera‘) >= 0 || navigator.userAgent.indexOf(‘Safari‘) >= 0 || navigator.userAgent.indexOf(‘Chrome‘) >= 0 || navigator.userAgent.indexOf(‘WebKit‘) >= 0){ if(window.history.length > 1){ window.history.go( -1 ); }else{ window.close() } }else{ //未知的浏览器 window.history.go( -1 ); } } }

 

 

根据history判断,有历史页就返回上一页,没有就关闭页面

原文:https://www.cnblogs.com/zhuMother/p/12335732.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!