


ASP.NET實現(xiàn)頁面刷新的方法
添加時間:2014-8-12 18:50:05
添加:
思海網(wǎng)絡
< meta http-equiv="refresh" content="300; url=target.html"> 用window.location.href實現(xiàn)刷新另個框架頁面
在寫asp.net程序的時候,我們經(jīng)常遇到跳轉(zhuǎn)頁面的問題,我們經(jīng)常使用Response.Redirect ,如果客戶要在跳轉(zhuǎn)的時候使用提示,這個就不靈光了,如:
Response.Write("< >alert('恭喜您,注冊成功!'); < />"); Response.Redirect("main.html"); 這時候我們的提示內(nèi)容沒有出來就跳轉(zhuǎn)了,和Response.Redirect("main.html"); 沒有任何區(qū)別。
這時我們采用下面代碼試驗一下ASP.NET頁面刷新:
Response.Write("< language=java>alert('恭喜您,注冊成功!')< />"); Response.Write("< language=java>window.location.href='main.html'< />"); 這個即實現(xiàn)了我們的要求,在提示后,跳轉(zhuǎn)頁面。
最重要的是window.location.href 語句可以實現(xiàn)一個框架的頁面在執(zhí)行服務器端代碼后刷新另一個框架的頁面(Response.Redirect無法達到,至少我沒有發(fā)現(xiàn)):
如:index.htm頁面中有二個框架,分別為 frameLeft和frameRight,在frameRight頁面中執(zhí)行服務器端代碼后刷新frameLeft中的頁面。
先前最常見的是注冊之后,自動刷新登陸框,讓登陸框換成已登陸頁面,只要在注冊成功的代碼之后加上一段,即可以實現(xiàn)刷新另個框架的頁面。代碼如下:
Response.Write("< language=java>alert('恭喜您,注冊成功!')< />"); Response.Write("< language=java>window.parent.frameLeft.location.href='main.html'< />"); ASP.NET頁面刷新:自動刷新頁面的實現(xiàn)方法總結(jié):
1)
< meta http-equiv="refresh"content="10; url=跳轉(zhuǎn)的頁面"> 10表示間隔10秒刷新一次
2)
< language=''java''> window.location.reload(true); < /> 如果是你要刷新某一個iframe就把window給換成frame的名字或ID號
3)
< language=''java''> window.navigate("本頁面url"); < /> 4>
function abc() { window.location.href="/blog/window.location.href"; setTimeout("abc()",10000); } 刷新本頁:
Response.Write("< language=java>window.location.href=window.location.href; < />") 刷新父頁:
Response.Write("< language=java>opener.location.href=opener.location.href; < />") 轉(zhuǎn)到指定頁:
Response.Write("< language=java>window.location.href='yourpage.aspx'; < />")
刷新頁面實現(xiàn)方式總結(jié)(HTML,ASP,JS)
'by aloxy
定時刷新:
1,
< >setTimeout("location.href='url'",2000)< /> 說明:url是要刷新的頁面URL地址
2000是等待時間=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,是等待的時間,以秒為單位
在寫asp.net程序的時候,我們經(jīng)常遇到跳轉(zhuǎn)頁面的問題,我們經(jīng)常使用Response.Redirect ,如果客戶要在跳轉(zhuǎn)的時候使用提示,這個就不靈光了,如:
Response.Write("< >alert('恭喜您,注冊成功!'); < />"); Response.Redirect("main.html"); 這時候我們的提示內(nèi)容沒有出來就跳轉(zhuǎn)了,和Response.Redirect("main.html"); 沒有任何區(qū)別。
這時我們采用下面代碼試驗一下ASP.NET頁面刷新:
Response.Write("< language=java>alert('恭喜您,注冊成功!')< />"); Response.Write("< language=java>window.location.href='main.html'< />"); 這個即實現(xiàn)了我們的要求,在提示后,跳轉(zhuǎn)頁面。
最重要的是window.location.href 語句可以實現(xiàn)一個框架的頁面在執(zhí)行服務器端代碼后刷新另一個框架的頁面(Response.Redirect無法達到,至少我沒有發(fā)現(xiàn)):
如:index.htm頁面中有二個框架,分別為 frameLeft和frameRight,在frameRight頁面中執(zhí)行服務器端代碼后刷新frameLeft中的頁面。
先前最常見的是注冊之后,自動刷新登陸框,讓登陸框換成已登陸頁面,只要在注冊成功的代碼之后加上一段,即可以實現(xiàn)刷新另個框架的頁面。代碼如下:
Response.Write("< language=java>alert('恭喜您,注冊成功!')< />"); Response.Write("< language=java>window.parent.frameLeft.location.href='main.html'< />"); ASP.NET頁面刷新:自動刷新頁面的實現(xiàn)方法總結(jié):
1)
< meta http-equiv="refresh"content="10; url=跳轉(zhuǎn)的頁面"> 10表示間隔10秒刷新一次
2)
< language=''java''> window.location.reload(true); < /> 如果是你要刷新某一個iframe就把window給換成frame的名字或ID號
3)
< language=''java''> window.navigate("本頁面url"); < /> 4>
function abc() { window.location.href="/blog/window.location.href"; setTimeout("abc()",10000); } 刷新本頁:
Response.Write("< language=java>window.location.href=window.location.href; < />") 刷新父頁:
Response.Write("< language=java>opener.location.href=opener.location.href; < />") 轉(zhuǎn)到指定頁:
Response.Write("< language=java>window.location.href='yourpage.aspx'; < />")
刷新頁面實現(xiàn)方式總結(jié)(HTML,ASP,JS)
'by aloxy
定時刷新:
1,
< >setTimeout("location.href='url'",2000)< /> 說明:url是要刷新的頁面URL地址
2000是等待時間=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,是等待的時間,以秒為單位
url是要刷新的頁面URL地址
關(guān)鍵字:ASP.NET、服務器
新文章:
- CentOS7下圖形配置網(wǎng)絡的方法
- CentOS 7如何添加刪除用戶
- 如何解決centos7雙系統(tǒng)后丟失windows啟動項
- CentOS單網(wǎng)卡如何批量添加不同IP段
- CentOS下iconv命令的介紹
- Centos7 SSH密鑰登陸及密碼密鑰雙重驗證詳解
- CentOS 7.1添加刪除用戶的方法
- CentOS查找/掃描局域網(wǎng)打印機IP講解
- CentOS7使用hostapd實現(xiàn)無AP模式的詳解
- su命令不能切換root的解決方法
- 解決VMware下CentOS7網(wǎng)絡重啟出錯
- 解決Centos7雙系統(tǒng)后丟失windows啟動項
- CentOS下如何避免文件覆蓋
- CentOS7和CentOS6系統(tǒng)有什么不同呢
- Centos 6.6默認iptable規(guī)則詳解