js定时刷新当前页面(js定时刷新页面)
大家好,今天来为大家解答js定时刷新当前页面这个问题的一些问题点,包括js定时刷新页面也一样很多人还不知道,因此呢,今天就来为大家分析分析,现在让我们一起来看看吧!如果解决了您的问题,还望您关注下本站哦,谢谢~
js怎么写2秒后再刷新当前页面
设置定时2秒后执行刷新。
<script type="text/javascript">
setTimeout(function(){//使用setTimeout()方法设定定时2000毫秒
window.location.reload();//页面刷新
},2000);
</script>
扩展资料:
html代码和JS代码的区别
一、基础不同
1、JS代码:基于原型编程、多范式的动态脚本语言,并且支持面向对象、命令式和声明式(如函数式编程)风格。
2、html代码:是由HTML命令组成的描述性文本,HTML命令可以说明文字、图形、动画、声音、表格、链接等。
二、用处不同
1、JS代码:用于Web应用开发,常用来为网页添加各式各样的动态功能,为用户提供更流畅美观的浏览效果。
2、html代码:结构包括头部(Head)、主体(Body)两大部分,其中头部描述浏览器所需的信息,而主体则包含所要说明的具体内容。
参考资料来源:百度百科-html代码
参考资料来源:百度百科-JS脚本
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常见的几种页面刷新方法如下:
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()">为页面关闭时刷新
OK,关于js定时刷新当前页面和js定时刷新页面的内容到此结束了,希望对大家有所帮助。