2011年4月6日 星期三

[轉]Javascript刷新頁面的幾種方法

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.
____________________________________________
框架頁中:(框架頁中其中一個子頁)
top.location.reload(); 刷新整頁 self.location.reload(); 刷新本頁
window.parent.location.href='' 框架頁重定向
_____________________________________________
自動刷新頁面的方法:
1.頁面自動刷新:把如下代碼加入<head>區域中<meta http-equiv="refresh" content="20">其中20指每隔20秒刷新一次頁面.<body onload ="opener.location.reload()"> 開窗時刷新<body onUnload="opener.location.reload()"> 關閉時刷新。
例:數據添加成功後彈出對話框並刷新頁面
if (infoAction_Sort.Insert(info_Sort)) ScriptManager.RegisterStartupScript(this.UpdatePanel, this.GetType(), "alert", "alert('相冊分類添加成功');window.location.reload();", true) ; //Alert("相冊分類創建成功");
                    
//Response.Redirect(Request.Url.ToString());//刷新本頁
                    
this.txt_AddSort.Text = "";
                    
this.txt_SortDepict.Text = "";
                
}

沒有留言:

張貼留言