js刷新页面 js刷新当前页面重新获取数据
大家好,今天小编来为大家解答以下的问题,关于js刷新页面,js刷新当前页面重新获取数据这个很多人还不知道,现在让我们一起来看看吧!
细谈JS刷新页面常用方法有哪些
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.location.rel="external nofollow" href="自定义页面地址";
自动刷新页面的方法:
在<head>标签中加入<meta http-equiv="refresh" content="10">
其中content是时间间隔,每10s刷新一次
在body中添加onload="opener.location.reload()",即<body onload="opener.location.reload()">为页面启动时刷新
在body中添加onUnload="opener.location.reload()",即<bodyonUnload="opener.location.reload()">为页面关闭时刷新
JS 页面刷新数据
Javascript刷新页面的几种方法:
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返回上一页并刷新的几种方法:
方法一:<a rel="external nofollow" href="javascript:history.go(-1)">返回上一页</a>
方法二:<a rel="external nofollow" href="javascript:location.reload()">刷新当前页面</a>
方法三:<a rel="external nofollow" rel="external nofollow" rel="external nofollow" href="javascript:" onclick="history.go(-2);">返回前两页</a>
方法四:<a rel="external nofollow" rel="external nofollow" rel="external nofollow" href="javascript:" onclick="self.location=document.referrer;">返回上一页并刷新</a>
方法五:<a rel="external nofollow" rel="external nofollow" rel="external nofollow" href="javascript:" onclick="history.back();">返回上一页</a>
扩展资料
JavaScript是一种属于网络的脚本语言,已经被广泛用于Web应用开发,常用来为网页添加各式各样的动态功能,为用户提供更流畅美观的浏览效果。通常JavaScript脚本是通过嵌入在HTML中来实现自身的功能的。
1、是一种解释性脚本语言(代码不进行预编译)。
2、主要用来向HTML(标准通用标记语言下的一个应用)页面添加交互行为。
3、可以直接嵌入HTML页面,但写成单独的js文件有利于结构和行为的分离。
4、跨平台特性,在绝大多数浏览器的支持下,可以在多种平台下运行(如Windows、Linux、Mac、Android、iOS等)。
Javascript脚本语言同其他语言一样,有它自身的基本数据类型,表达式和算术运算符及程序的基本程序框架。Javascript提供了四种基本的数据类型和两种特殊数据类型用来处理数据和文字。而变量提供存放信息的地方,表达式则可以完成较复杂的信息处理。
参考资料来源:百度百科:javascript
关于js刷新页面的内容到此结束,希望对大家有所帮助。