.Net刷新页面的小结
现在给大家讲讲在.Net中书信页面的几种方式:
第一:
private void Button1_Click( object sender, System.EventArgs e )
{
Response.Redirect( Request.Url.ToString( ) );
}
第二:
private void Button2_Click( object sender, System.EventArgs e )
{
Response.Write( "
<script language=javascript>window.location.href=document.URL;
</script>" );
}
第三:
private void Button3_Click( object sender, System.EventArgs e )
{
Response.AddHeader( "Refresh","" );
}
第四:
private void Button6_Click( object sender, System.EventArgs e )
{
//好像有些不对?
//Response.Write( "
<script language=javascript>window.location.reload( );
</script>" );
}
第五:(需替换<>)
<script><!--
var limit="3:00"
if ( document.images )
{
var parselimit=limit.split( ":" )parselimit=parselimit[]*+parselimit[]*
}
function beginrefresh( )
{
if ( !document.images )returnif ( parselimit== )window.location.reload( )else
{
parselimit-=1curmin=Math.floor( parselimit/ )cursec=parselimit`if ( curmin!= )curtime=curmin+"分"+cursec+"秒后重刷本页!"elsecurtime=cursec+"秒后重刷本页!"window.status=curtimesetTimeout( "beginrefresh( )", )
}
}
window.onload=beginrefresh//--> </script><DIV style="Z-INDEX: 102;
LEFT: 408px;
POSITION: absolute;
TOP: 232px" ms_positioning="text2D">
<><FONT size="">自动刷新页面</FONT></P>
</DIV>第六:
<meta http-equiv="refresh" content="300;
url=target.html"> 、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、 非模态刷新父页面:window.opener.location.reload();
模态刷新父页面:window.dialogArguments.location.reload(); 先来看一个简单的例子:
下面以三个页面分别命名为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[].location.reload();
语句2. window.parent.frames.bottom.location.reload();
语句3. window.parent.frames["bottom"].location.reload();
语句4. window.parent.frames.item().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> 解释一下:
.window指代的是当前页面,例如对于此例它指的是top.html页面。
.parent指的是当前页面的父页面,也就是包含它的框架页面。例如对于此例它指的是framedemo.html。
.frames是window对象,是一个数组。代表着该框架内所有子页面。
.item是方法。返回数组里面的元素。
.如果子页面也是个框架页面,里面还是其它的子页面,那么上面的有些方法可能不行。 附:
Javascript刷新页面的几种方法:
history.go()
location.reload()
location=location
location.assign(location)
document.execCommand('Refresh')
window.navigate(location)
location.replace(location)
document.URL=location.href 自动刷新页面的方法:
.页面自动刷新:把如下代码加入<head>区域中
<meta http-equiv="refresh" content="">
其中20指每隔20秒刷新一次页面. .页面自动跳转:把如下代码加入<head>区域中
<meta http-equiv="refresh" content="20;url=http://blog.sina.com/samtanjie">
其中20指隔20秒后跳转到http://blog.sina.com/samtanjie页面 .页面自动刷新js版
<script language="JavaScript">
function myrefresh()
{
window.location.reload();
}
setTimeout('myrefresh()',); //指定1秒刷新一次
</script> ASP.NET如何输出刷新父窗口脚本语句
. this.response.write("<script>opener.location.reload();</script>"); . this.response.write("<script>opener.window.location.href = opener.window.location.href;</script>"); . 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="javascriptpener.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">
window.opener.document.location.reload()
</script>
.Net刷新页面的小结的更多相关文章
- js刷新页面方法大全
如何实现刷新当前页面呢?借助js你将无所不能. 1,reload 方法,该方法强迫浏览器刷新当前页面.语法:location.reload([bForceGet]) 参数: bForceGet, ...
- 不使用Ajax,如何实现表单提交不刷新页面
不使用Ajax,如何实现表单提交不刷新页面? 目前,我想到的是使用<iframe>,如果有其他的方式,后续再补. 举个栗子: 在表单上传文件的时候必须设置enctype="mul ...
- 三种上传文件不刷新页面的方法讨论:iframe/FormData/FileReader
发请求有两种方式,一种是用ajax,另一种是用form提交,默认的form提交如果不做处理的话,会使页面重定向.以一个简单的demo做说明: html如下所示,请求的路径action为"up ...
- .net 刷新页面防止表单二次提交
1.页面上按钮是服务器控件,现在刷新页面要防止按钮事件重复执行 原网址:http://blog.csdn.net/high_mount/article/details/51066056
- JS定时刷新页面及跳转页面
JS定时刷新页面及跳转页面 Javascript 返回上一页1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2); 2. history ...
- 刷新页面时 select值保持不变
刷新页面时,要使下拉菜单(select).raido保持不变,用ajax是无法实现的.我想只能通过cookies才能实现.刷新前先把select或radio的值保存在cookies中,刷新后再填回去. ...
- js 刷新页面window.location.reload();
Javascript刷新页面的几种方法:1 history.go(0)2 window.location.reload() window.location.reload(true) 3 ...
- 发现meta有个刷新页面的办法。
meta是html中不可缺少的一个标签,它的应用以方便浏览器搜索并分类当前网页的内容. meta总是放在head标签的第一个位置.今天我在复习前端知识的时候,在网上发现了用meta刷新网页的好办法. ...
- 利用js刷新页面方法
1,reload 方法,该方法强迫浏览器刷新当前页面. location.reload(force) 如果该方法没有规定参数,或者参数是 false,它就会用 HTTP 头 If-Modified-S ...
随机推荐
- mysql 误删除ibdata1之后如何恢复
mysql 误删除ibdata1之后如何恢复 如果误删除了在线服务器中mysql innodb相关的数据文件ibdata1以及日志文件 ib_logfile*,应该怎样恢复呢? 这时候应该一身冷汗了吧 ...
- Chp17: Moderate
17.1 swap a number in place.(without temporary variables) a = a ^ b; b = a ^ b; a = a ^ b; 17.3 Writ ...
- 设计模式(Design Patterns——可复用面向对象软件的基础
设 计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了可重用代码.让代码更容易被他人理解.保证代 码可靠性. 毫无疑问 ...
- 使用wget和ftp共享文件
一.需求 有一个机器A,上面那有很多文件.现在新买一个机器B,不想用U盘复制,就想把A弄成个服务器,然后B登录到A,想要什么文件就下载什么文件. 二.Win7实现 A是Win7和Ubuntu双系统,首 ...
- mysql外键详解
1.1.MySQL中“键”和“索引”的定义相同,所以外键和主键一样也是索引的一种.不同的是MySQL会自动为所有表的主键进行索引,但是外键字段必须由用户进行明确的索引.用于外键关系的字段必须在所有的参 ...
- ios开发跳转
如果我的是A->B->C后,我想直接从 C->A 应该怎么做???这是我的问题 看了这个帖子不太明白 这是10楼的解决办法 , 虽然 写的很清楚 ,但是还是没懂啊 ...
- 各种分区类型对应的partition_Id
ID Name Note == ==== ==== 00h empty [空] 01h DOS 12-bit FAT [MS DOS FAT12] 02h XENIX root file system ...
- Android AIDL-跨进程
Android在设计理念上强调组件化,组件之间的依赖性很小.我们往往发一个Intent请求就可以启动另一个应用的Activity,或者一个你不知道在哪个进程的Service,或者可以注册一个广播,只要 ...
- Java API —— 泛型
1.泛型概述及使用 JDK1.5以后出现的机制 泛型是一种特殊的类型,它把指定类型的工作推迟到客户端代码声明并实例化类或方法的时候进行.也被称为参数化类型,可以把类型当作参数一样传递过来,在传递过来之 ...
- python生成验证码脚本
最近每天都用python写一个小的脚本,练习使用python语法. 验证码的生成: 这里使用了python的图像处理库PIL,安装PIL的过程中出了一个小麻烦,就使用Pillow-win32的一个文件 ...