2009年1月11日

window:特徵三頁

window | 特徵一頁 | 二頁 | 三頁 | 四頁 | 五頁
方法一頁 | 二頁 | 三頁 | 四頁 | 五頁 | 六頁 | 七頁
操控器一頁 | 二頁 | 三頁 | 四頁 | 五頁 | 六頁 | 七頁 | 成員表
window 的特徵

使用這些特徵時,可以用 window.property;也可以省略 window,直接用 property。

name

讀取或設定視窗的名稱。

  • 程式用法:

    <script type='text/javascript'>
    window.name='myPage';
    document.write( window.name );
    </script>

  • 執行結果:

    myPage

存放 navigator 物件。

opener

存有開啟當下網頁的父網頁。沒有父網頁時,內存 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 的輸出結果不同了。
parent

存放當下視窗或子矩框的父視窗物件其位址,如果沒有父視窗,則傳回自身的位址。

  • 程式用法:

    <script type='text/javascript'>
    document.write( window.parent.location );
    </script>

  • 執行結果:

    http://ant4js.blogspot.com/2009/01/windowptyv3.html

pkcs11

存放 pkcs11 物件。限 Firefox 使用。

returnValue

請參考 showModalDialog() 的範例。

self

存放本視窗自己的物件位址。

  • 程式用法:

    <script type='text/javascript'>
    document.write( window.self.location );
    </script>

  • 執行結果:

    http://ant4js.blogspot.com/2009/01/windowptyv3.html

sessionStorage

請參見 Storage

top

存放視窗階層的最上面一個視窗的物件。此特徵常用在視窗被矩框分割時。

  • 程式用法:

    <script type='text/javascript'>
    document.write( top.navigator.appName );
    </script>

  • 執行結果:

    Netscape

window

存放本視窗的物件。

  • 程式用法:

    <script type='text/javascript'>
    document.write( window.window.navigator.appName );
    </script>

  • 執行結果:

    Netscape


©2008-2009 by ant2legs, All Rights Reserved. ant2legs 擁有其製作的文章,圖片與程式的著作權,所有權利保留。