1,reload方法
该方法强迫浏览器刷新当前页面。
语法:location.reload()
2,replace方法
当使用replace方法之后,不能通过“前进”和“后退”来访问已经被替换的URL。
语法: location.replace(URL)
返回并刷新页面:
location.replace(document.referrer);
document.referrer //前一个页面的URL
不要用 history.go(-1),或 history.back();来返回并刷新页面,这两种方法不会刷新页面。
Javascript刷新页面的几种方法:
<script>
history.go(0)
location.reload()
location=location
location.assign(location)
document.execCommand('Refresh')
window.navigate(location) //这个方法是只针对IE的,不适用于火狐等其他浏览器(不推荐)!!!建议忘记
location.replace(location)
document.URL=location.href
</script>
自动刷新页面的方法:
1,页面自动刷新:把如下代码加入区域中
<meta http-equiv="refresh" content="20">
(其中20指每隔20秒刷新一次页面.)
2,页面自动跳转:把如下代码加入区域中
<meta http-equiv="refresh" content="20;url=http://www.baidu.com">
(其中20指隔20秒后跳转到http://www.baidu.comt页面)
3,页面自动刷新js版
<script type="text/javascript">
function myrefresh()
{
window.location.reload();
}
setTimeout('myrefresh()',100); //指定100毫秒刷新一次
</script>