第一次加载后刷新页面,但如果我再次刷新页面,则刷新页面? [英] Refresh the page after first load but not if I refresh it again?

查看:116
本文介绍了第一次加载后刷新页面,但如果我再次刷新页面,则刷新页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在第一次加载后重新加载我的html页面,但是如果刷新页面,不要重新加载。我所做的是:

  window.onload = function(){
if(!window.location.hash ){
window.location = window.location +'#loaded';
window.location.reload();
}
}

但是如果我刷新页面,重新加载,我不想要。有没有解决方案可以避免这种情况?提前致谢。

解决方案

尝试设置cookie并检查

I want to reload my html page just after it loads for the first time, but not to reload if page is refreshed. What I have done is:

 window.onload = function() {
    if(!window.location.hash) {
        window.location = window.location + '#loaded';
        window.location.reload();
    }
   }

But with this approach if I refresh the page it gets reloaded which I don't want. Are there any solutions to avoid this? Thanks in advance.

解决方案

Try setting the cookie and check

这篇关于第一次加载后刷新页面,但如果我再次刷新页面,则刷新页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆