`
wlh269
  • 浏览: 449236 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

js页面刷新总结

阅读更多
2)
<script>
window.location.reload(true);
</script>
如果是你要刷新某一个iframe就把window给换成frame的名字或ID号
3)
<script>
window.navigate("本页面url");
</script>
4>

function abc()
{
window.location.href="/blog/window.location.href";
setTimeout("abc()",10000);
}

刷新本页:
Response.Write("<script>window.location.href=window.location.href;</script>")

刷新父页:
Response.Write("<script>opener.location.href=opener.location.href;</script>")

转到指定页:
Response.Write("<script>window.location.href='yourpage.aspx';</script>")
刷新页面实现方式总结(HTML,ASP,JS)
'by aloxy

定时刷新:
1,<script>setTimeout("location.href='url'",2000)</script>

说明:url是要刷新的页面URL地址
2000是等待时间=2秒,

2,

说明:
n is the number of seconds to wait before loading the specified URL.
url is an absolute URL to be loaded.
n,是等待的时间,以秒为单位
url是要刷新的页面URL地址

3,<!--sponse.redirect ur-->

说明:一般用一个url参数或者表单传值判断是否发生某个操作,然后利用response.redirect 刷新。

4,刷新框架页
   〈script language=javascript>top.leftFrm.location.reload();parent.frmTop.location.reload(); 弹出窗体后再刷新的问题

Response.Write("<script>window.showModalDialog('../OA/SPCL.aspx',window,'dialogHeight: 300px; dialogWidth: 427px; dialogTop: 200px; dialogLeft: 133px')</script>");//open
             Response.Write("<script>document.location=document.location;</script>");

在子窗体页面代码head中加入

刷新的内容加在    if (!IsPostBack) 中

在框架页中右面刷新左面
    //刷新框架页左半部分
    Response.Write("<script>");
    Response.Write("parent.left.location.href='PayDetailManage_Left.aspx'");
    Response.Write("</script>");

页面定时刷新功能实现

有三种方法:
1,在html中设置:
之後加入下面这一行即可!
定时刷新:
10代表刷新间隔,单位为秒

2.jsp
<!--esponse.setHeader("refresh","1");-->
每一秒刷新一次

3.使用javascript:
<script>
setTimeout("self.location.reload();",1000);
<script>
一秒一次


页面自动跳转:

<script>
window.location.href="mian.aspx";
history.go(0);//window.close();   //关闭浏览器此页的窗口
</script>

先来看一个简单的例子:
下面以三个页面分别命名为frame.html、top.html、bottom.html为例来具体说明如何做。

frame.html 由上(top.html)下(bottom.html)两个页面组成,代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> frame </TITLE>
</HEAD>
<frameset rows="50%,50%">
<frame name=top src="top.html">
<frame name=bottom src="bottom.html">
</frameset>
</HTML>
现在假设top.html (即上面的页面) 有七个button来实现对bottom.html (即下面的页面) 的刷新,可以用以下七种语句,哪个好用自己看着办了。

语句1. window.parent.frames[1].location.reload();
语句2. window.parent.frames.bottom.location.reload();
语句3. window.parent.frames["bottom"].location.reload();
语句4. window.parent.frames.item(1).location.reload();
语句5. window.parent.frames.item('bottom').location.reload();
语句6. window.parent.bottom.location.reload();
语句7. window.parent['bottom'].location.reload();

top.html 页面的代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
  <TITLE> top.html </TITLE>
</HEAD>
<BODY>
<input type=button value="刷新1" onclick="window.parent.frames[1].location.reload()"><br>
<input type=button value="刷新2" onclick="window.parent.frames.bottom.location.reload()"><br>
<input type=button value="刷新3" onclick="window.parent.frames['bottom'].location.reload()"><br>
<input type=button value="刷新4" onclick="window.parent.frames.item(1).location.reload()"><br>
<input type=button value="刷新5" onclick="window.parent.frames.item('bottom').location.reload()"><br>
<input type=button value="刷新6" onclick="window.parent.bottom.location.reload()"><br>
<input type=button value="刷新7" onclick="window.parent['bottom'].location.reload()"><br>
</BODY>
</HTML>
下面是bottom.html页面源代码,为了证明下方页面的确被刷新了,在装载完页面弹出一个对话框。

bottom.html 页面的代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
  <TITLE> bottom.html </TITLE>
</HEAD>
<BODY onload="alert('我被加载了!')">
<h1>This is the content in bottom.html.</h1>
</BODY>
</HTML>
解释一下:
1.window指代的是当前页面,例如对于此例它指的是top.html页面。
2.parent指的是当前页面的父页面,也就是包含它的框架页面。例如对于此例它指的是framedemo.html。
3.frames是window对象,是一个数组。代表着该框架内所有子页面。
4.item是方法。返回数组里面的元素。
5.如果子页面也是个框架页面,里面还是其它的子页面,那么上面的有些方法可能不行。

附:
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

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

2.页面自动跳转:把如下代码加入<head>区域中
<meta http-equiv="refresh" content="20;url=http://www.wyxg.com">
其中20指隔20秒后跳转到http://www.wyxg.com页面

3.页面自动刷新js版
<script language="JavaScript">
function myrefresh()
{
     window.location.reload();
}
setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>

ASP.NET如何输出刷新父窗口脚本语句
1. this.response.write("<script>opener.location.reload();</script>");

2. this.response.write("<script>opener.window.location.href = opener.window.location.href;</script>");  

3. Response.Write("<script language=javascript>opener.window.navigate(''你要刷新的页.asp'');</script>")


JS刷新框架的脚本语句

//如何刷新包含该框架的页面用   
<script language=JavaScript>
parent.location.reload();
</script>  

//子窗口刷新父窗口
<script language=JavaScript>
   self.opener.location.reload();
</script>
( 或 <a href="javascript:opener.location.reload()">刷新</a>   )

//如何刷新另一个框架的页面用   
<script language=JavaScript>
parent.另一FrameID.location.reload();
</script>

如果想关闭窗口时刷新或者想开窗时刷新的话,在<body>中调用以下语句即可。

<body onload="opener.location.reload()"> 开窗时刷新
<body onUnload="opener.location.reload()"> 关闭时刷新

<script language="javascript">

文章出处:http://www.diybl.com/course/4_webprogram/ajax/ajaxxl/2008922/144561.html
分享到:
评论
3 楼 liulehua 2010-10-11  
总结的不错
2 楼 wlh269 2010-06-23  
  
1 楼 xwq18 2010-05-28  
  

相关推荐

    javascript 页面刷新和模态对话框 学习总结 推荐哦

    本人总结和转摘的 有关 JavaScript 页面刷新和 模态对话框的总结知识,这几天用到了不少, 上传,大家共享共进步。 以后还会有更多的 JavaScript 学习知识相关总结。 都为原创。。

    基于JavaScript判断浏览器到底是关闭还是刷新(超准确)

    页面刷新时先执行onbeforeunload,然后onunload,最后onload。 经过验证我得出的结论是: //对于ie,谷歌,360: //页面加载时只执行onload //页面刷新时,刷新之前执行onbeforeunload事件,在新页面即将替换旧页面...

    JavaScript刷新页面的几种方法总结

    该方法强迫浏览器刷新当前页面。 语法:location.reload([bForceGet]) 参数: bForceGet, 可选参数, 默认为 false,从客户端缓存里取当前页。true, 则以 GET 方式,从服务端取最新的页面, 相当于客户端点击 F5(...

    JS刷新当前页面的几种方法总结

    本篇文章主要是对JS刷新当前页面的几种方法进行了详细的总结介绍,需要的朋友可以过来参考下,希望对大家有所帮助

    JS关于刷新页面的相关总结

    很多程序员无论是新手还是老的程序员都避免不了关于JS刷新页面的相关内容,在本文中我们整理了软件开发网总结的关于JS页面刷新的相关重要知识点文章,一起来跟着学习下。 JS刷新当前页面的几种方法总结 reload 方法...

    JavaScript上传文件时不用刷新页面方法总结(推荐)

    主要介绍了JavaScript上传文件时不用刷新页面方法,用js+css代码详细介绍了操作过程,需要的朋友可以参考下

    JS在一定时间内跳转页面及各种刷新页面的实现方法

    软件开发网整理的关于JS刷新页面相关的总结://www.jb51.net/article/139788.htm 1.js 代码: [removed] var time = 5; //时间,秒 var timelong = 0; function diplaytime(){ //时间递减 document.all.his[removed...

    刷新页面实现方式总结(HTML,ASP,JS)

    多种方法实现页面的刷新代码

    详解vue几种主动刷新的方法总结

    当我们在做项目时,我们需要做当前页面的刷新来达到数据更新的目的,在此我们大概总结了几种常用的页面刷新的方法。 1.[removed].reload(),是原生JS提供的方法,this.$router.go(0):是vue路由里面的一种方法,这两种...

    javascript弹出窗口问题总结

    javascript弹出窗口问题总结 1.无提示刷新网页 2.javascript刷新页面的方法 3.javascript弹出窗口代码 4.模式窗口数据不刷新(缓存)问题 5.模式窗口中,链接弹出新窗口问题 6.无提示关闭页面的方法

    JS实用的密码强度提示及验证码(不需要刷新)

    有玩过动网的人应该知道它在注册和登录页中都有验证码这一项,这验证码...注意,只刷新验证码,页面其他部分没刷新哦!以前我专门针对这个研究了好久,查阅了资料,后来总结成一篇文章叫"script调用asp实现过程",有兴

    JS针对浏览器窗口关闭事件的监听方法集锦

    本文实例总结了JS针对浏览器窗口关闭事件的监听方法。分享给大家供大家参考,具体如下: 方式一:(适用于IE浏览器,而且刷新不提示,只在点击浏览器关闭按钮的时候提示) [removed] [removed]=onclose; function ...

    react-router browserHistory刷新页面404问题解决方法

    使用React开发新项目时,遇见了刷新页面,直接访问二级或三级路由时,访问失败,出现404或资源加载异常的情况,本篇针对此问题进行分析并总结解决方案。 背景 使用webpack-dev-server做本地开发服务器时,正常情况...

    刷新页面的几种方法小结(JS,ASP.NET)

    本篇文章只要是对刷新页面的几种方法进行了详细的总结介绍,包括JS与ASP.NET。需要的朋友可以过来参考下,希望对大家有所帮助

    使用Firebug对js进行断点调试的图文方法

    如果断点已经执行过,则刷新页面,这时脚本就会在断点处中断。如果断点没有执行过,那可以直接执行页面上的动作(例如点击按钮等),然后代码会在断点处中断; d. 观察函数调用栈,观察local变量,也可以进行单步...

Global site tag (gtag.js) - Google Analytics