解决微信界面返回问题

把代码写在1页面的点击进入下一级的事件中,点击手机自带的返回就会有效果,(事列:所有页面在一个网页中显示,控制显隐)
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('后退');

$(".wxxxl").hide();
$("#soxxxxng").show();
soslist(state);局部刷新,重新请求数据函数
} 
}

});
window.history.pushState('forward', null, "http://xxxxx?xxx=xxx&xx等需要刷新的界面地址"); 
}

posted @ 2022-06-23 18:11  ·一库  阅读(511)  评论(0)    收藏  举报