页面自动刷新代码大全,基本上所有要求自动刷新页面的代码都有,大家可以自由发挥做出完mei的页面。
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
window.location.reload(true);</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
如果是你要刷新某一个iframe就把window给换成frame的名字或ID号
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
window.navigate("本页面url");</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
window.location.href="/blog/window.location.href";
setTimeout("abc()",10000);
Response.Write("window.location.href=window.location.href;")
Response.Write("opener.location.href=opener.location.href;")
Response.Write("window.location.href='yourpage.aspx';")
1,setTimeout("location.href='url'",2000)
n is the number of seconds to wait before loading the specified URL.
url is an absolute URL to be loaded.
说明:一般用一个url参数或者表单传值判断是否发生某个操作,然后利用response.redirect 刷新。
〈script language=javascript>top.leftFrm.location.reload();parent.frmTop.location.reload(); 弹出窗体后再刷新的问题
Response.Write("window.showModalDialog('../OA/SPCL.aspx',window,'dialogHeight: 300px; dialogWidth: 427px; dialogTop: 200px; dialogLeft: 133px')");//open
Response.Write("document.location=document.location;");
刷新的内容加在 if (!IsPostBack) 中
Response.Write("");</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
Response.Write("parent.left.location.href='PayDetailManage_Left.aspx'");</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
Response.Write("");
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
setTimeout("self.location.reload();",1000);</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
<script></p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
一秒一次</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
页面自动跳转:</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
<script></p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
window.location.href="mian.aspx";</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
history.go(0);//window.close(); //关闭浏览器此页的窗口</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
下面以三个页面分别命名为frame.html、top.html、bottom.html为例来具体说明如何做。
frame.html 由上(top.html)下(bottom.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();
下面是bottom.html页面源代码,为了证明下方页面的确被刷新了,在装载完页面弹出一个对话框。
This is the content in bottom.html.
1.window指代的是当前页面,例如对于此例它指的是top.html页面。
2.parent指的是当前页面的父页面,也就是包含它的框架页面。例如对于此例它指的是framedemo.html。
3.frames是window对象,是一个数组。代表着该框架内所有子页面。
5.如果子页面也是个框架页面,里面还是其它的子页面,那么上面的有些方法可能不行。
4 location.assign(location)
5 document.execCommand('Refresh')
6 window.navigate(location)
7 location.replace(location)
8 document.URL=location.href
其中20指隔20秒后跳转到http://www.wyxg.com页面
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
function myrefresh()</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
{</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
window.location.reload();</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
}</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
setTimeout('myrefresh()',1000); //指定1秒刷新一次</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
1. this.response.write("opener.location.reload();");
2. this.response.write("opener.window.location.href = opener.window.location.href;");
3. Response.Write("opener.window.navigate(''你要刷新的页.asp'');")
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
parent.location.reload();</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
self.opener.location.reload();</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
parent.另一FrameID.location.reload();</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">
window.opener.document.location.reload()</p>
<p style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 20px; padding-top: 0px; font-size: 14px; line-height: 24px; text-indent: 24px; ">