asp.net 頁(yè)面刷新的實(shí)現(xiàn)方法
來(lái)源:易賢網(wǎng) 閱讀:683 次 日期:2014-10-21 10:09:34
溫馨提示:易賢網(wǎng)小編為您整理了“asp.net 頁(yè)面刷新的實(shí)現(xiàn)方法”,方便廣大網(wǎng)友查閱!

asp.net 頁(yè)面刷新的實(shí)現(xiàn)方法,比較全了, 包括html與js下的實(shí)現(xiàn)方法。

先看看asp.net頁(yè)面刷新的實(shí)現(xiàn)方法:

第一:

c# code

private void button1_click( object sender, system.eventargs e )

{

response.redirect( request.url.tostring( ) );

}

第二:

c# code

private void button2_click( object sender, system.eventargs e )

{

response.write( < script language=javascript>window.location.href=document.url; < /script> );

}

第三:

c# code

private void button3_click( object sender, system.eventargs e )

{

response.addheader( refresh,0 );

}

第四:

c# code

private void button6_click( object sender, system.eventargs e )

{

//好像有些不對(duì)?

//response.write( < script language=javascript>window.location.reload( ); < /script> ); }

第五:

html code

< script>< !-- var limit=3:00 if ( document.images ) { var parselimit=limit.split( : )parselimit=parselimit[0]*60+parselimit[1]*1 } function beginrefresh( ) { if ( !document.images )returnif ( parselimit==1 )window.location.reload( )else { parselimit-=1curmin=math.floor( parselimit/60 )cursec=parselimit%60if ( curmin!=0 )curtime=curmin+分+cursec+秒后重刷本頁(yè)!elsecurtime=cursec+秒后重刷本頁(yè)!window.status=curtimesettimeout( beginrefresh( ),1000 ) } } window.onload=beginrefresh//--> < /script>< div style=z-index: 102; left: 408px; position: absolute; top: 232px ms_positioning=text2d> < p>< font size=3>自動(dòng)刷新頁(yè)面< /font>< /p> < /div>

第六:

< meta http-equiv=refresh content=300; url=target.html> 用window.location.href實(shí)現(xiàn)刷新另個(gè)框架頁(yè)面

在寫asp.net程序的時(shí)候,我們經(jīng)常遇到跳轉(zhuǎn)頁(yè)面的問題,我們經(jīng)常使用response.redirect ,如果客戶要在跳轉(zhuǎn)的時(shí)候使用提示,這個(gè)就不靈光了,如:

response.write( < script>alert('恭喜您,注冊(cè)成功!'); < /script>); response.redirect(main.html); 這時(shí)候我們的提示內(nèi)容沒有出來(lái)就跳轉(zhuǎn)了,和response.redirect(main.html); 沒有任何區(qū)別。

這時(shí)我們采用下面代碼試驗(yàn)一下asp.net頁(yè)面刷新:

response.write( < script language=javascript>alert('恭喜您,注冊(cè)成功!') < /script>); response.write( < script language=javascript>window.location.href='main.html' < /script>); 這個(gè)即實(shí)現(xiàn)了我們的要求,在提示后,跳轉(zhuǎn)頁(yè)面。

最重要的是window.location.href 語(yǔ)句可以實(shí)現(xiàn)一個(gè)框架的頁(yè)面在執(zhí)行服務(wù)器端代碼后刷新另一個(gè)框架的頁(yè)面(response.redirect無(wú)法達(dá)到,至少我沒有發(fā)現(xiàn)):

如:index.htm頁(yè)面中有二個(gè)框架,分別為 frameleft和frameright,在frameright頁(yè)面中執(zhí)行服務(wù)器端代碼后刷新frameleft中的頁(yè)面。

先前最常見的是注冊(cè)之后,自動(dòng)刷新登陸框,讓登陸框換成已登陸頁(yè)面,只要在注冊(cè)成功的代碼之后加上一段,即可以實(shí)現(xiàn)刷新另個(gè)框架的頁(yè)面。代碼如下:

response.write( < script language=javascript>alert('恭喜您,注冊(cè)成功!') < /script>); response.write( < script language=javascript>window.parent.frameleft.location.href='main.html' < /script>); asp.net頁(yè)面刷新:自動(dòng)刷新頁(yè)面的實(shí)現(xiàn)方法總結(jié):

1)

< meta http-equiv=refreshcontent=10; url=跳轉(zhuǎn)的頁(yè)面> 10表示間隔10秒刷新一次

2)

< script language=''javascript''> window.location.reload(true); < /script> 如果是你要刷新某一個(gè)iframe就把window給換成frame的名字或id號(hào)

3)

< script language=''javascript''> window.navigate(本頁(yè)面url); < /script> 4>

function abc() { window.location.href=/blog/window.location.href; settimeout(abc(),10000); } 刷新本頁(yè):

response.write( < script language=javascript>window.location.href=window.location.href; < /script>) 刷新父頁(yè):

response.write( < script language=javascript>opener.location.href=opener.location.href; < /script>) 轉(zhuǎn)到指定頁(yè):

response.write( < script language=javascript>window.location.href='yourpage.aspx'; < /script>)

刷新頁(yè)面實(shí)現(xiàn)方式總結(jié)(html,asp,js)

'by aloxy

定時(shí)刷新:

1,

< script>settimeout(location.href='url',2000) < /script> 說明:url是要刷新的頁(yè)面url地址

2000是等待時(shí)間=2秒,

2,

< meta name=refresh content=n; url> 說明:

n is the number of seconds to wait before loading the specified url.

url is an absolute url to be loaded.

n,是等待的時(shí)間,以秒為單位

url是要刷新的頁(yè)面url地址

3,

< %response.redirect url%> 說明:一般用一個(gè)url參數(shù)或者表單傳值判斷是否發(fā)生某個(gè)操作然后利用response.redirect 刷新。

4,刷新框架頁(yè)

〈script language=javascript>top.leftfrm.location.reload(); parent.frmtop.location.reload(); < /script〉 彈出窗體后再刷新的問題

response.write( < script>window.showmodaldialog('../oa/spcl.aspx',window,'dialogheight: 300px; dialogwidth: 427px; dialogtop: 200px; dialogleft: 133px') < /script>); //open response.write( < script>document.location=document.location; < /script>); 在子窗體頁(yè)面代碼head中加入 < base target=_self/>

刷新的內(nèi)容加在 if (!ispostback) 中

在框架頁(yè)中右面刷新左面

//刷新框架頁(yè)左半部分 response.write( < script language=javascript>); response.write(parent.left.location.href='paydetailmanage_left.aspx'); response.write( < /script>);

頁(yè)面定時(shí)刷新功能實(shí)現(xiàn)

有三種方法:

1,在html中設(shè)置:

< title>xxxxx < /title>之後加入下面這一行即可!

定時(shí)刷新:

< meta http-equiv=refresh content=10> 10代表刷新間隔,單位為秒

2.jsp

< % response.setheader(refresh,1); %> 每一秒刷新一次

3.使用javascript:

< script language=javascript> settimeout(self.location.reload(); ,1000); < script> 一秒一次

頁(yè)面自動(dòng)跳轉(zhuǎn):

1,在html中設(shè)置:

< title>xxxxx < /title>之後加入下面這一行即可!

定時(shí)跳轉(zhuǎn)并刷新:

< meta http-equiv=refresh content=20; url=http://自己的url>, 其中20指隔20秒后跳轉(zhuǎn)到http://自己的url 頁(yè)面。

點(diǎn)擊按鈕提交表單后刷新上級(jí)窗口

a窗口打開b窗口

然后在b里面提交數(shù)據(jù)至c窗口

最后要刷新a窗口

并且關(guān)閉b窗口

幾個(gè)javascript函數(shù)

//第一個(gè)自動(dòng)關(guān)閉窗口

< script language=javascript> < !-- function clock(){i=i-1 document.title=本窗口將在+i+秒后自動(dòng)關(guān)閉!; if(i>0)settimeout(clock(); ,1000); else self.close(); } var i=2 clock(); //--> < /script> //第二個(gè)刷新父頁(yè)面的函數(shù)

< script language=javascript> opener.location.reload(); < /script> //第三個(gè)打開窗口

< script language=javascript> function show(mylink,mytitle,width,height) {mailwin=window.open(mylink,mytitle,'top=350,left=460,width='+width+',height='+height+',scrollbars=no')} < /script> 有關(guān)asp.net頁(yè)面刷新的問題,收藏這幾種方法會(huì)有用的。

更多信息請(qǐng)查看IT技術(shù)專欄

更多信息請(qǐng)查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機(jī)網(wǎng)站地址:asp.net 頁(yè)面刷新的實(shí)現(xiàn)方法
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國(guó)考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號(hào)
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)