Html 单击链接时刷新页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20783015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:12:09  来源:igfitidea点击:

Refresh page when clicked on link

htmlbrowser-cache

提问by Benny

I have the following to refresh my page when clicked on href.

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

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

I have this

我有这个

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

in the head tag. Even then I am getting a cached copy. How can I avoid loading cached copy?

在头部标签中。即使那样,我也会得到一个缓存副本。如何避免加载缓存副本?

回答by Green Wizard

instead of

代替

javascript:history.go(0);

you may use

你可以使用

javascript:window.location.reload();

回答by NiksD

<a onclick="window.location.href=this">test</a>

回答by scrblnrd3

In your <meta>tag, you're missing a content attribute. try this

在您的<meta>标签中,您缺少内容属性。尝试这个

<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" />

You could also try

你也可以试试

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

but I'm not sure how that would work with regards to caching

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

回答by Istiaque Ahmed

Try This:

尝试这个:

   <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>

Used jquery

使用jquery

回答by Rakesh Kumar

Try this

尝试这个

window.location.href=window.location.href