最近在做项目中遇到一个需在微信端ios刷新的问题,接下来和大家分享一下解决方法
运用HTML5新的API,history.pushState()
$(function(){
if (window.history && window.history.pushState) {
//window对象上的onpopstate事件,响应浏览器的后退事件
$(window).on('popstate', function() {
window.location.href = "<{:U('User/myData')}>" //页面跳转并刷新
});
//通过history.pushState()激活的历史记录条目,才能在点击浏览器回退按钮时触发popstate事件
window.history.pushState({}, null, "<{:U('Message/msgList')}>");
}
})
网友评论