Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  javascript  >  正文 js刷新页面几种方法小结

js刷新页面几种方法小结

发布时间:2015-06-20   编辑:www.jquerycn.cn
本文介绍了javascript刷新页面的几种方法,包括reload、replace等方法,有需要的朋友参考下。

js代码中实现刷新页面的方法,包括:
 

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.

框架页中:(框架页中其中一个子页)
 

top.location.reload();   刷新整页 
self.location.reload();  刷新本页

window.parent.location.href='' 框架页重定向

自动刷新页面的方法:
1,页面自动刷新:把如下代码加入<head>区域中<meta http-equiv="refresh" content="20">其中20指每隔20秒刷新一次页面。
 

复制代码 代码示例:
<body onload="opener.location.reload()"> 开窗时刷新
<body onunload="opener.location.reload()"> 关闭时刷新。

例:数据添加成功后弹出对话框并刷新页面
 

复制代码 代码示例:
if (infoaction_sort.insert(info_sort))
{
    scriptmanager.registerstartupscript(this.updatepanel, this.gettype(), "alert", "alert('相册分类添加成功');window.location.reload();", true);
  
    //alert("相册分类创建成功");
    //response.redirect(request.url.tostring());//刷新本页
    this.txt_addsort.text = "";
    this.txt_sortdepict.text = "";
}

您可能感兴趣的文章:
js刷新页面几种方法小结
js定时刷新页面与跳转页面多种方法
jQuery 定时局部刷新(setInterval)方法总结
js自动刷新当前页面方法详解
js自动刷新页面代码汇总
js返回上一页并刷新的几种方法
js返回上一页并刷新多种方法举例
asp网页自动刷新方法汇总
js刷新当前页面的几种方法
js返回上一页并刷新的多种方法

关键词: 刷新页面   
[关闭]