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

script刷新页面,刷新代码,页面自动刷新代码

 
阅读更多
页面自动刷新代码大全,基本上所有要求自动刷新页面的代码都有,大家可以自由发挥做出完美的页面。
1)

10表示间隔10秒刷新一次
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>
( 或 刷新   )

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

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

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

<script language="javascript">
window.opener.document.location.reload()
</script>


原文地址::http://blog.csdn.net/liu_zhongjie/article/details/3333731
1
2
分享到:
评论

相关推荐

    网页页面 自动刷新的3种代码

    1.页面自动刷新:把如下代码加入&lt;head&gt;区域中 &lt;meta http-equiv="refresh" content="20"&gt;,其中20指每隔20秒刷新一次页面. 2.页面自动跳转:把如下代码加入&lt;head&gt;区域中 &lt;meta ...

    javascript 强制刷新页面的实现代码

    Javascript刷新页面的几种方法: 1 history.go(0) 2 location....8 document.URL=location.href 自动刷新页面的方法: 1.页面自动刷新:把如下代码加入&lt;head&gt;区域中 &lt;meta http-equiv=”refresh” content=”20

    500多个html网页格式的各种源代码

    1.3 页面自动刷新.htm 1.4 页面的后退、刷新、前进.htm 1.5 保护网页源代码.htm 1.6 保护自己的网页不被放入框架.htm 1.7 打印页面的出错原因.htm 1.8 当前网页调用其他网页.htm 1.9 倒计时载入页面.htm ...

    jsp 刷新父页面

    用iframe、弹出子页面刷新父页面 iframe parent.location.reload(); 弹出子页面 window.opener.location.reload(); 子窗口刷新父窗口 self.window.opener.locaction.reload(); 刷新一open()方法打开的窗口 ...

    javascript 页面只自动刷新一次

    1.看看下面这段代码 代码如下: [removed] function reurl(){ url = location.href;... //刷新页面 } } onload=reurl [removed] 2.原理 充分利用地址栏可带参数的选项,用脚本来取得页面间的传递参数

    script不刷新页面的联动前后代码

    如何实现script不刷新页面的联动,在本文有个不错的示例或许对大家有所帮助

    javascript web页面刷新的方法收集

    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....

    auto-refresh-safari:使用任何编辑器编辑网站(html)源码的时候,自动为您在Safari浏览器中打开页面(如果页面已经打开,则自动为您刷新)

    如果能有一个工具,当我们保存文档的时候,自动刷新页面就好了。 自动刷新就是完成这个功能的小工具。注意事项本应用程序使用AppleScript(Windows / Linux用户,不好意思了)编写,启动时会提示用户选择网站页面...

    asp验证码-带刷新-最简洁的验证码代码

    asp验证码,带刷新,代码简洁 验证源码只有55行,超简洁 引用方式: 验证码: &lt;input name="txt_check" type="text" size=6 maxlength=4 class="input"&gt; 验证码,看不清楚?请点击刷新验证码" height="10" style=...

    [原创]帝国cms7.0无刷新Ajax登录退出、ajax注册信息验证插件

    2.在合适的位置加上这段代码:&lt;span id="show_userinfo"&gt;&lt;/span&gt; 3.先在head之间引入jquery库,然后页面底部引入js文件: &lt;script type="text/javascript" src="/e/member/AjaxLog/?loadjs=1"&gt;&lt;/script&gt;

    JS中利用localStorage防止页面动态添加数据刷新后数据丢失

    非常不多说了,直接给大家贴代码了,具体代码如下所示: &lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8" /&gt; &lt;meta name="viewport" content="width=device-width,...

    Javascript实现返回上一页面并刷新的小例子

    同时要求返回上一页面,并实现对上一页面的操作进行刷新(例如删除的,添加的),在网上搜寻了一遍,基本上90%的都是说的是用window.history.go(-1), 或者是用 window.history.back(-1), 还有的说子页面刷新父页面用...

    javascript跳转与返回和刷新页面的实例代码

    location.href(‘index.html’) 表示在当前窗口重定向到新页面,打开并刷新 index.html 这个页面 [removed] 是 window 对象的属性,用来替换当前页,也就是重新定位当前页 而window.open 是 window 对象的方法,是...

    javascript showModalDialog 多层模态窗口实现页面提交及刷新的代码

    替换 location.href 当需要关闭第N(N&gt;1)层的模态窗口,并刷新第N-1层的模态页面时, 为防止刷新时弹出新窗口, 可以通过returnValue 以传递返回值给第N-1层模态窗口,来确认是否需要刷新 在按钮的提交事件中: 代码 ...

    javaScript实例自学手册486例,附带目录可方便搜索

    1.3 页面自动刷新.htm 1.30 代码测试页面.htm 1.31 屏幕式左右拉开页面的效果.htm 1.32 下雨的页面.htm 1.33 页面背景颜色渐变.htm 1.34 自动滚屏.htm 1.35 在页面中画点.htm 1.36 页面顶部颜色渐变特效.htm...

    java script 调试工具 脚本控制台

    4, USE:选择需要调试的页面,当无效的选项过多时请刷新页面 5, 随机命名:当一个页面同时被打开多次时,需要选中此项。如:test.jsp,test.jsp?id=1, test.jsp?id=30 小技巧:先开启脚本控制台页面,被调试的...

    Javascript 刷新全集常用代码

    一:刷新本页面 前台:[removed][removed].href=[removed].href;[removed] 后台:Response.Write(“[removed][removed].href=[removed].href;[removed]”) 二:刷新父页面 前台:opener.location.href=opener....

    javascript刷新父页面的各种方法汇总

    用iframe、弹出子页面刷新父页面iframe [removed] parent.location.reload(); [removed] 弹出子页面 [removed] window.opener.location.reload(); [removed] 子窗口刷新父窗口 [removed] self.opener.location....

    原创jquery实现点击按钮后倒计时效果,防页面刷新!

    同时把倒计时数据写入 cookie 防止页面被刷新 4.倒计时的实现不采用全局变量,避免污染全局,或被其他函数修改。 5.按钮点击时先判断 cookie 里面有没有保存的倒计时值,如果有就从该值开 始倒计时。同时锁定...

Global site tag (gtag.js) - Google Analytics