【问题标题】:Refresh page when clicked on link [duplicate]单击链接时刷新页面[重复]
【发布时间】:2014-01-14 00:03:04
【问题描述】:

单击 href 时,我有以下内容可以刷新我的页面。

    <a href="javascript:history.go(0)">Click to refresh the page</a>

我有这个

    <meta http-equiv="no-cache"> 

在head标签中。即使这样,我也得到了一个缓存副本。如何避免加载缓存副本?

【问题讨论】:

    标签: html browser-cache


    【解决方案1】:

    而不是

    javascript:history.go(0);
    

    你可以使用

    javascript:window.location.reload();
    

    【讨论】:

      【解决方案2】:
      <a onclick="window.location.href=this">test</a>
      

      【讨论】:

        【解决方案3】:

        在您的&lt;meta&gt; 标记中,您缺少内容属性。试试这个

        <meta http-equiv="expires" content="0" />
        <meta http-equiv="cache-control" content="max-age=0" />
        <meta http-equiv="expires" content="-1" />
        <meta http-equiv="pragma" content="no-cache" />
        <meta http-equiv="cache-control" content="no-cache" />
        

        你也可以试试

        <a href="javascript:window.location.reload();">
        

        但我不确定这在缓存方面如何工作

        【讨论】:

        • 没有工作...仍在加载缓存副本
        • 那应该更跨浏览器
        【解决方案4】:

        试试这个

        window.location.href=window.location.href
        

        【讨论】:

          【解决方案5】:

          试试这个:

             <a class="refresh_link" href="javascript:void(0)">click to Refresh the Page</a>
          
          
          <script type="text/javascript">
          
          $(document).ready(function(){
          
          
          
              $(".refresh_link").click(function(){
          
               location.reload();
          
          
          
              });
          
          });
          </script>
          

          使用jquery

          【讨论】:

          • 没用。还包含 jQuery 库
          • @Benny,至少更新了吗?尝试先清除浏览器缓存。
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-02-11
          • 1970-01-01
          • 2016-01-27
          • 2012-11-15
          • 2021-06-14
          • 2023-03-13
          相关资源
          最近更新 更多