2010年5月26日 星期三

window onload 的幾種寫法


window.onload=function(){
 call_block();
}

ASP.NET如何輸出刷新父窗口腳本語句
1.  this.response.write("<script>opener.location.reload();</script>"); 


2.  this.response.write("<script>opener.window.location.href = opener.window.location.href;</script>");  

3.  Response.Write("<script language=javascript>opener.window.navigate(''你要刷新的頁.asp'');</script>")




//如何刷新包含該框架的頁面用   
<script language=JavaScript>
  parent.location.reload();
</script>  

//子窗口刷新父窗口
<script language=JavaScript>
   self.opener.location.reload();
</script>

( 或 <a href="javascript:opener.location.reload()">刷新</a>   )

//如何刷新另一個框架的頁面用   
<script language=JavaScript>
  parent.另一FrameID.location.reload();
</script>


<body onload="opener.location.reload()">
開窗時刷新
<body onUnload="opener.location.reload()">
關閉時刷新

<script language="javascript">
window.opener.document.location.reload()
</script>

如果直接把新動作附在 window.onload 的話,是會把前一個 window.onload 的動作給蓋掉的




所以建議這樣做






var oldOnload = window.onload || function () {};

window.onload = function () {
oldOnload();
// Do What Tou Want..
}



把舊的 window.onload 設定成一個變數,
然後在新的 window.onload 裡呼叫它