方法有很多种,简单有效的2种:
1. java:
<script type=’text/javascript’>
(function()
{
if( window.localStorage )
{
if( !localStorage.getItem( ‘firstLoad’ ) )
{
localStorage[ ‘firstLoad’ ] = true;
window.location.reload();
}
else
localStorage.removeItem( ‘firstLoad’ );
}
})();
</script>
2. html 代码 (可以添加到header 里)
<body onload="if (location.href.indexOf('reload')==-1) {location.replace(location.href+'?reload')}">

本文介绍两种简单有效的方法来实现网页的刷新操作,一种是通过Java本地存储实现页面的首次加载检查和刷新,另一种是在HTML中使用body onload事件实现条件刷新。
944

被折叠的 条评论
为什么被折叠?



