方法一頁 | 二頁 | 三頁 | 四頁 | 五頁 | 六頁 | 七頁
操控器一頁 | 二頁 | 三頁 | 四頁 | 五頁 | 六頁 | 七頁 | 成員表
使用這些特徵時,可以用 window.property;也可以省略 window,直接用 property。
存放視窗內的 document 物件。
視窗所在的矩框(frame)。如果視窗是最上層,IE, Firefox 傳回 null;Safari, Chrome 傳回 undefined。
- 程式用法:
<iframe width='90%' height='500px'
src='http://ant4js.blogspot.com/2009/02/frameelement.html'>
</iframe> - 執行結果:
內存當下視窗中的子矩框組之清單。可以用 window.frames[指標].member,取得矩框成員。window.frames[指標] 也是是一個 window 物件,所有 window 的特徵與方法都可以使用。
- 程式用法:
<script type='text/javascript'>
document.write( window.frames.length );
</script>
<ol>
<script type='text/javascript'>
for(var i=0; i < window.frames.length; i++ )
document.write( '<li>'+ window.frames[i].name );
</script>
</ol> - 執行結果:
1
- 不同瀏覽器輸出不同。
視窗為全螢幕時為 true,否則為 false。限 Firefox 使用。
- 程式用法:
<script type='text/javascript'>
document.write( window.fullScreen );
</script> - 執行結果:
[object HTMLDivElement]
請參見 Storage。
存放瀏覽器的展示頁(session)的 history 物件。
瀏覽器文件展現區的長與寬,包括捲軸鈕(scroll bar)。唯讀。其值為整數,單位為像素(pixel)。
- 程式用法:
<script type='text/javascript'>
document.write( window.innerHeight +'<br />');
document.write( window.innerWidth );
</script> - 執行結果:
720
1280
- IE 沒這兩項;Firefox, Safari, Chrome 都成功。
存放視窗中矩框的數目。
- 程式用法:
<script type='text/javascript'>
document.write( window.length );
</script> - 執行結果:
1
存放文件的 location 物件。