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