C#刷新页面的六种方法

第一:

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( "

" );

}

第三:

private void Button3_Click( object sender, System.EventArgs e )

{

Response.AddHeader( "Refresh","0" );

}

第四:

private void Button6_Click( object sender, System.EventArgs e )

{

//Response.Write( "

" );

}

第五:(需替换<>)

自动刷新页面

第六:

用window.location.href实现刷新另个框架页面

在写https://www.360docs.net/doc/409149605.html,程序的时候,我们经常遇到跳转页面的问题,我们经常使用Response.Redirect ,如果客户要在跳转的时候使用提示,这个就不灵光了,如:

Response.Write(""); Response.Redirect("main.html");

这时候我们的提示内容没有出来就跳转了,和Response.Redirect("main.html");没有任何区别。

这时我们采用下面代码试验一下:

Response.Write("");

Response.Write("

language=javascript>window.location.href='main.html'");

这个即实现了我们的要求,在提示后,跳转页面。

最重要的是window.location.href 语句可以实现一个框架的页面在执行服务器

端代码后刷新另一个框架的页面(Response.Redirect无法达到,至少我没有发现):

如:index.htm页面中有二个框架,分别为frameLeft和frameRight,在frameRight页面中执行服务器端代码后刷新frameLeft中的页面。

先前最常见的是注册之后,自动刷新登陆框,让登陆框换成已登陆页面,只要在注册成功的代码之后加上一段,即可以实现刷新另个框架的页面。代码如下:

Response.Write("");

Response.Write("

language=javascript>window.parent.frameLeft.location.href='main.html'");

自动刷新页面的实现方法总结:

1)

10表示间隔10秒刷新一次

2)

如果是你要刷新某一个iframe就把window给换成frame的名字或ID号

3)

4>

function abc()

{

window.location.href="/blog/window.location.href";

setTimeout("abc()",10000);

}

刷新本页:

Response.Write("

language=javascript>window.location.href=window.location.href;")

刷新父页:

Response.Write("

language=javascript>opener.location.href=opener.location.href;")

转到指定页:

Response.Write("

language=javascript>window.location.href='yourpage.aspx';")

刷新页面实现方式总结(HTML,ASP,JS)

'by aloxy

定时刷新:

1,

说明: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,<%response.redirect url%>

说明:一般用一个url参数或者表单传值判断是否发生某个操作,然后利用response.redirect 刷新。

4,刷新框架页

〈script

language=javascript>top.leftFrm.location.reload();parent.frmTop.location.reloa d();

弹出窗体后再刷新的问题

Response.Write("");//open

Response.Write("");

页面定时刷新功能实现

有三种方法:

1,在html中设置:

xxxxx之後加入下面这一行即可!

定时刷新:

10代表刷新间隔,单位为秒

2.jsp

<% response.setHeader("refresh","1"); %>

每一秒刷新一次

3.使用javascript:

//第二个刷新父页面的函数

//第三个打开窗口

用Js脚本实现页面跳转

1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2); 2. history.back(). 3. window.history.forward()返回下一页 4. window.history.go(返回第几页,也可以使用访问过的URL) 例: 向上一页 response.Write("") response.Write("") 向上一页 页面跳转:onclick="window.location.href='list.aspx'" P.S. 小技巧(JS引用JS): 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.页面自动刷新:把如下代码加入区域中 其中20指每隔20秒刷新一次页面.

window.location.reload();页面实现跳转和刷新

window.location.reload();页面实现跳转和刷新 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 这几个都可以刷新 window.location.reload();刷新

window.location.href=window.location.href;刷新 window.close();关闭窗口,不弹出系统提示,直接关闭 window.close()相当于self属性是当前窗口 window.parent.close()是parent属性是当前窗口或框架的框架组 页面实现跳转的九种方法实例: <html> < head> < meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> < title>navigate</title> < script language="javascript">

setTimeout('window.navigate("top.html");',2000); setTimeout('window.document.location.href="top.html";',20 00); setTimeout('window.document.location="top.html";',2000); setTimeout('window.location.href="top.html";',2000); setTimeout('window.location="top.html";',2000); setTimeout('document.location.href="top.html";',2000); setTimeout('document.location="top.html";',2000); setTimeout('location.href="top.html";',2000); setTimeout('location.replace("top.html")',2000);

JS关闭窗口弹出新窗口,关闭新窗口时,刷新父窗口,JS代码实现刷新网页,js实现弹出窗口代码收集集萃

经常上网的朋友可能到过这样一些网站,一进入首页立刻会弹出一个窗口,或者按一个链接或按钮弹出,通常在这个窗口里会显示一些注意事项、版权信息、警告、欢迎光顾之类的话或者作者想要特别提示的信息。其实制作这样的页面非常容易,只要往该页面的HTML里加入几段javascript代码即可实现。下面我就带你剖析它的奥秘。 【最基本的弹出窗口代码】 其实代码非常简单: 因为这是一段javascript代码,所以它们应该放在之间。是对一些版本低的浏览器起作用,在这些老浏览器中如果不支持javascript,不会将标签中的代码作为文本显示出来。 Window.open ('page.html')用于控制弹出新的窗口page.html,如果page.html不与主窗口在同一路径下,前面应写明路径,绝对路径(http://)和相对路径(../)均可。 用单引号和双引号都可以,只是不要混用。 这一段代码可以加入HTML的任意位置,加入到和之间也可以,位置越靠前执行越早,尤其是页面代码较长时,又想使页面早点弹出就尽量往前放。 【经过设置后的弹出窗口】 下面再说一说弹出窗口外观的设置。只要再往上面的代码中加一点东西就可以了。 我们来定制这个弹出窗口的外观、尺寸大小、弹出位置以适应该页面的具体情况。

验证码: 看不清?

js弹出窗口总结6种弹窗方法

js弹出窗口总结6种弹窗方法 注: //关闭,父窗口弹出对话框,子窗口直接关闭 this.Response.Write(""); //关闭,父窗口和子窗口都不弹出对话框,直接关闭 this.Response.Write(""); //弹出窗口刷新当前页面width=200 height=200菜单。菜单栏,工具条,地址栏,状态栏全没有 this.Response.Write(""); //弹出窗口刷新当前页面 this.Response.Write(""); this.Response.Write(" "); //关闭当前子窗口,刷新父窗口 this.Response.Write(""); this.Response.Write(""); //子窗口刷新父窗口 this.Response.Write(""); this.Response.Write("");

『总结』JS常用方法与片段

『总结』JS常用方法与片段 1.javascript删除元素节点IE中有这样一个方 法:removeNode(),这个方法在IE下是好使的,但是在Firefox等标准浏览器中就会报错了removeNode is not defined,但是在核心JS中有一个操作DOM节点的方法叫:removeChild()。我们可以先去找到要删除节点的父节点,然后在父节点中运用removeChild来移除我们想移除的节点。我们可以定义一个方法叫removeElement:function removeElement(_element){ var _parentElement = _element.parentNode; if(_parentElement){ _parentElement.rem oveChild(_element); }}2.js sort方法根据数组中对象的某一个属性值进行升序或者降序排列/**数组根据数 组对象中的某个属性值进行排序的方法* 使用例子:newArray.sort(sortBy('number'),false) //表示根据number属性降序排列;若第二个参数不传递,默认表示升序排序* @param attr 排序的属性如number属性* @param rev true表示升序排列,false降序排序* */ sortBy: function(attr,rev){ //第二个参数没有传递默认升序排列if(rev == undefined){ rev = 1; }else{ rev = (rev) ? 1 : -1; }

return function(a,b){ a = a[attr]; b = b[attr]; if(a return rev * -1; } if(a > b){ return rev * 1; } return 0; } }3.charCodeAt()用法:charCodeAt() 方法可返回指定位置的字符的Unicode 编码。这个返回值是0 - 65535 之间的整数 语法:stringObject.charCodeAt(index) index参数必填,表示字符串中某个位置的数字,即字符在字符串中的下标。 注:字符串中第一个字符的下标是0。如果index 是负数,或大于等于字符串的长度,则charCodeAt() 返回NaN。例如:var str='Hello world!'document.write(str.charCodeAt(1))//结果:1014.js 页面刷新location.reload和location.replace的区别小结reload 方法,该方法强迫浏览器刷新当前页面。 语法:location.reload([bForceGet]) 参数:bForceGet,可选参数,默认为false,从客户端缓存里取当前页。true, 则以GET 方式,从服务端取最新的页面, 相当于客户端点击F5(“刷新”)replace 方法,该方法通过指定URL替换当前缓存在历史里(客户端)的项目,因此当使用replace方法之后,你不能通过“前进”和“后退”来

C#刷新页面的六种方法

第一: 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( " " ); } 第三: private void Button3_Click( object sender, System.EventArgs e ) { Response.AddHeader( "Refresh","0" ); } 第四: private void Button6_Click( object sender, System.EventArgs e ) { //Response.Write( " " ); } 第五:(需替换<>)