当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jquery判断浏览器后退时候弹出消息的方法教程

jquery判断浏览器后退时候弹出消息的方法教程

2018年03月18日  | 移动技术网IT编程  | 我要评论
浏览器后退时必定会有一些消息,这里使用jquery判断浏览器后退并弹出消息 jQuery(document).ready(function ($) { if (wind

浏览器后退时必定会有一些消息,这里使用jquery判断浏览器后退并弹出消息

jQuery(document).ready(function ($) {
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
var hashLocation = location.hash;
var hashSplit = hashLocation.split("#!/");
var hashName = hashSplit[1];
if (hashName !== '') {
var hash = window.location.hash;
if (hash === '') {
alert("Back button isn't supported. You are leaving this application on next clicking the back button");
}
}
});
window.history.pushState('forward', null, './#forward');
}
});

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网