Refresh page when clicked on link [duplicate]

点点圈 提交于 2020-01-12 03:29:09

问题


I have the following to refresh my page when clicked on 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?


回答1:


instead of

javascript:history.go(0);

you may use

javascript:window.location.reload();



回答2:


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



回答3:


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

<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




回答4:


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




回答5:


Try this

window.location.href=window.location.href


来源:https://stackoverflow.com/questions/20783015/refresh-page-when-clicked-on-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!