百度搜到的返回歷史頁
1. JS 重載頁面,本地刷新,返回上一頁?
<a href="javascript:history.go(-1)">返回上一頁</a>
<a href="javascript:location.reload()">重載頁面,本地刷新</a>
<a href="javascript:history.go(-1);location.reload()">返回上一頁重載頁面,本地刷新</a>
2. 返回前兩頁
?history.go(-2); location.reload();?
3. 返回上一頁并強制刷新
<a href="#" onclick="self.location=document.referrer;">返回</a>
history.go(-2); location.reload();?
跳轉頁面代碼:
1??? history.go(0)? ??
2??? location.reload()
3??? location=location
4??? location.assign(location)
5??? document.execCommand('Refresh')
6??? window.navigate(location)
7??? location.replace(location)
8??? document.URL=location.href
自動刷新頁面的方法,但以下方法會頁面閃動,不是我想要的效果:
1.頁面自動刷新:把如下代碼加入<head>區(qū)域中
?<meta http-equiv="refresh" content="20">?
其中20指每隔20秒刷新一次頁面.
2.頁面自動跳轉:把如下代碼加入<head>區(qū)域中
?<meta http-equiv="refresh" content="20;url=http://www.javaeye.com">
20秒后自動跳到指定頁面.
3.頁面自動刷新js版
<script language="JavaScript">
function myrefresh()
{
?????? window.location.reload();
}
setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>
jsp清除緩存(親測無效)
?????<meta http-equiv="pragma" content="no-cache">
???? <meta http-equiv="cache-control" content="no-cache">
???? <meta http-equiv="expires" content="0">??
? ?或
? ??response.setHeader("Pragma","No-cache");?
????response.setHeader("Cache-Control","no-cache");?
????response.setDateHeader("Expires", 0);?
親測以上方法都無效或不是我想要的效果,然后找到了一種取巧的方法
在地址后加時間戳? ? var url="www.baidu.com?nocache="+new Date().getTime();
在地址后加隨機數? ??var url="www.baidu.com?nocache="+Math.random();
回到頁面時瀏覽器獲取到地址不同會強制刷新一次