Document對象可以更新正在裝入或已經裝入的文檔,並可以訪問裝入文檔所包含的HTML元素,Document對象是一個頂層對象,不需要預先實例化可直接使用。
Document屬性
form屬性:通過document.Forms[]數組來使得在同一個頁面上可以有多個相同的表單窗體,使用forms[]
數組比使用表單名字方便,即Document.form[n](Document.formName)。
eg:
<form name="frm1">
textbox1:<input type="text" width="279" onChange="document.my.elements[0].value=this.value;">
</form>
<form name="my">
textbox2:<input type="text" width="279" onChange="document.frm1.elements[0].value=this.value;">
</form>
titile屬性:使用document.title可以得到當前頁面中包含在<title>對中的標題
URL屬性:使用document.URL可以得到當前網頁的路徑。
Open()和Close()方法:和window一樣。
Write()和writeln()方法:
DOcument對象的集合:
集合 |
說明 |
anchors |
頁面中所有錨的集合(由<a name="anchorname"></a>表示) |
applets |
頁面中所有applet的結合 |
embeds |
頁面中所有嵌套式對象的集合(有<embed/>標籤表示) |
forms |
頁面中有表單的集合 |
images |
頁面中所有圖像的集合 |
links |
頁面中所有鏈接的集合(由<a href="somewhere.htm"></a>表示) |
location對象