javascript刷新指定窗口

定时自动刷新本页面

例如,每20秒刷新本页面,把下面代码加入到head块

<meta http-equiv="refresh" content="20">

 

到时自动调整到指定页面

例如,20秒后调转到www.xxx.xxx页面,把下面代码加入到head块

<meta http-equiv="refresh" content="20;url=http://www.xxx.xxx">

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

 

框架页面中,刷新指定窗口,用javascript

parent.location.reload();     //子窗口刷新父窗口
self.opener.location.reload();    //子窗口刷新打开该子窗口的窗口
parent.otherFrameID.location.reload();   //自窗口刷新兄弟窗口
top.location.reload();     //子窗口刷新顶级窗口(或根窗口)

 

打开或关闭页面时刷新 //未测试
<body οnlοad="opener.location.reload()"> 打开页面时刷新
<body onUnload="opener.location.reload()"> 关闭页面时刷新
<script language="javascript"> 打开页面时刷新
window.opener.document.location.reload()
</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>")

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

 

 

 

 

JavaScript Refresh Button

<html>

<head>
<title>Refresh Button Example</title>
<script language="JavaScript">
<!--

//  The "refresh" function implementations are identical
//  to our regular "JavaScript-Refresh" example.  The only
//  difference from our JavaScript Refresh example is
//  we do not have a doLoad function that starts our
//  refresh timer (since we use a refresh button).

var sURL = unescape(window.location.pathname);

function refresh()
{
    window.location.href = sURL;
}
//-->

</script>

<script language="JavaScript1.1">
<!--
function refresh()
{
    window.location.replace( sURL );
}
//-->

</script>

<script language="JavaScript1.2">
<!--
function refresh()
{
    window.location.reload( false );
}
//-->

</script>
</head>

<body>

<script language="JavaScript">
<!--
    // we put this here so we can see something change
    document.write('<b>' + (new Date).toLocaleString() + '</b>');
//-->

</script>

<!--

    In every example that we use below, we simply call the "refresh"
    JavaScript function.
   
    Our first example uses a "link" that invokes the JavaScript function.
-->

<p><a href="javascript:refresh()">Refresh Link</a></p>

<!--
    The "image" button is nothing more than an image nested in a link.
-->

<p><a href="javascript:refresh()"><img src="images/button_green.gif" border="0"
align="middle" width="71" height="70"
>
</a>image as a button</p>

<!--
    The last method ties into the "onclick" event for a form button.
-->

<form method="GET" action="refreshbutton.htm">
  <p><input type="button" οnclick="refresh()" value="Refresh Form Button"
  name="button1"
>
</p>
</form>

</body>

</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值