event.persisted判断是否后退进入
后退返回
window.addEventListener(‘pageshow’, function (event) {
if (event.persisted || window.performance &&
window.performance.navigation.type == 2)
{
location.reload();
}
},false);
event.persisted从缓存冲获取时为true否则为false,谷歌浏览器及Ie浏览器不起作用可使用上面的方法判断
<script type="text/javascript">
window.addEventListener('pageshow', function (event) {
if (event.persisted|| window.performance && window.performance.navigation.type == 2){
document.getElementById("enter").style.opacity=0
location.reload();
}
});
</script>