close

按此前往javascript完整教學目錄

 

 

1. window物件,所指的就是瀏覽器視窗本身,在網頁物件中是最上層的物件。以下是網頁物件的類別架構圖(紫灰色是本章介紹的部分)

未命名

一般來說,在一張網頁文件檔中,要呼叫documentnavigatorscreen等等window物件的成員物件(或稱「子物件」),正確的程式碼寫法應如:

window.document.成員

window.navigator.成員

window.screen.成員

等等。

但由上圖可知,window是整張網頁檔中最上層的物件,故在呼叫window物件的成員物件時,程式碼也可以省略掉window,如:

document.成員

navigator.成員

screen.成員

等等。

 

2. 在此,必須先說明視窗的「家族關係」,這與框架(傳統框架以及嵌入式框架)有關。設,在伺服器資料夾中,有test1.phptest2.phptest3.php三個網頁文件檔:

test1.php內容程式碼為:

<body style="color:#063">

這是test1這是test1這是test1這是test1這是test1這是test1這是test1這是test1

這是test1這是test1這是test1這是test1這是test1這是test1這是test1這是test1

</body>

test2.php內容程式碼為:<body>這是test2</body>

test3.php內容程式碼為:<body>這是test3</body>

又,在伺服器資料夾中,有frametest.php網頁文件檔,內容程式碼為:

<body>

<iframe src="test1.php" width="300" height="50" 

style="position:absolute; top:50px; left:10px; "></iframe>

<iframe src="test2.php" width="300" height="50"  marginwidth="30"

style="position:absolute; top:150px; left:10px;"></iframe>

<iframe src="test3.php" width="300" height="50"

style="position:absolute; top:250px; left:10px;"></iframe>

</body>

執行frametest.php後顯示:

h

這時,我們可以說:frametest.php的視窗」是「test1.php 的視窗」

、「test2.php 的視窗」、「test3.php 的視窗」三者的「父視窗」。可畫視窗架構圖

為:

image

 

在以上的架構圖中,「frametest.php的視窗」沒有父視窗,於是我們稱:frametest.php的視窗」是整個架構的「始祖視窗」。

 

3. 視窗的「前景」與「後景」之分:後景視窗會被前景視窗遮蓋住,而後景視窗的標題列之顏色較淡。如圖:

image

 

 

 

 

上一篇:javascript-正規表達式

下一篇:window物件的成員函式

arrow
arrow

    埃伯 發表在 痞客邦 留言(0) 人氣()