/**
* 监听手机返回键或浏览器后退键并自定义跳转地址
* oldUrl 本页对应的url
* backUrl 后退到页面的Url
*/
function backBtnToUrl(oldUrl,backUrl){
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 === '') {
location.href = backUrl;
}
}
});
window.history.pushState('forward', null, oldUrl);
}
}
监听手机返回键或浏览器后退键并自定义跳转地址
最新推荐文章于 2024-07-08 13:45:00 发布