方法一頁 | 二頁 | 三頁 | 四頁 | 五頁 | 六頁 | 七頁
操控器一頁 | 二頁 | 三頁 | 四頁 | 五頁 | 六頁 | 七頁 | 成員表
使用這些特徵時,可以用 window.property;也可以省略 window,直接用 property。
讀取或設定視窗的名稱。
- 程式用法:
<script type='text/javascript'>
window.name='myPage';
document.write( window.name );
</script> - 執行結果:
myPage
存放 navigator 物件。
存有開啟當下網頁的父網頁。沒有父網頁時,內存 null。opener 是一個 window 物件,所有 window 的特徵與方法都可以使用。
- 程式用法:
<script type='text/javascript'>
document.write( window.opener
+'<br />'+ window.opener.location.href );
</script>
<p><a href='http://ant4js.blogspot.com/2008/12/windowptynz.html#opener'
target=_blank>請點此開啟子視窗</a> - 執行結果:
- 在子視窗中,opener 的輸出結果不同了。
存放當下視窗或子矩框的父視窗物件其位址,如果沒有父視窗,則傳回自身的位址。
- 程式用法:
<script type='text/javascript'>
document.write( window.parent.location );
</script> - 執行結果:
http://ant4js.blogspot.com/2009/01/windowptyv3.html
存放 pkcs11 物件。限 Firefox 使用。
請參考 showModalDialog() 的範例。
存放本視窗自己的物件位址。
- 程式用法:
<script type='text/javascript'>
document.write( window.self.location );
</script> - 執行結果:
http://ant4js.blogspot.com/2009/01/windowptyv3.html
請參見 Storage。
存放視窗階層的最上面一個視窗的物件。此特徵常用在視窗被矩框分割時。
- 程式用法:
<script type='text/javascript'>
document.write( top.navigator.appName );
</script> - 執行結果:
Netscape
存放本視窗的物件。
- 程式用法:
<script type='text/javascript'>
document.write( window.window.navigator.appName );
</script> - 執行結果:
Netscape