.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 ...
随机推荐
- java基础知识回顾之---java String final类构造方法
/** * String 构造方法学习 * String(byte[ ] bytes):通过byte数组构造字符串对象. * String(byte[] bytes, int offs ...
- SDUT2482二叉排序树
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2482&cid=1184 题目描述 二叉排序树的定义是:或者是一棵空树,或者是具有下列性质 ...
- hdu 4277 USACO ORZ
没什么好方法,只能用dfs了. 代码如下: #include<iostream> #include<cstring> #include<cstdio> #inclu ...
- poj 1026 Cipher
置换群就可以搞定!!! 注意下格式就好了…… #include<iostream> #include<stdio.h> #include<algorithm> #i ...
- Android 加载时在actionBar右上角添加一个加载图标
①首先要在Activity的 setContentView()方法前调用requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); // ...
- 【mongoDB中级篇①】游标cursor
简述 通俗的说,游标不是查询结果,可以理解为数据在遍历过程中的内部指针,其返回的是一个资源,或者说数据读取接口. 客户端通过对游标进行一些设置就能对查询结果进行有效地控制,如可以限制查询得到的结果数量 ...
- mybatis和hibernate区别和应用场景
hibernate:是一个标准ORM框架(对象关系映射).入门门槛较高的,不需要程序写sql,sql语句自动生成了. 对sql语句进行优化.修改比较困难的. 应用场景: 适用与需求变化不多的中小型项目 ...
- Git教程之工作区和暂存区(5)
工作区(Working Directory) 就是你在电脑里能看到的目录,比如我的learngit文件夹就是一个工作区:
- sonar runner 2.4
https://www.versioneye.com/java/org.codehaus.sonar.runner:sonar-runner-dist/2.4
- Learning Lua Programming (2) Lua编程基础
开始学习Lua编程,首先从一些简单的语法开始. 一.编辑环境 下面推荐一个Lua编程的IDE,感觉是很强大的.ZeroBrane Studio,windows平台,mac平台都有.点击打开链接 官方 ...