Js隨記

Document對象 在javasprict中比較重要,幾乎所有的操作都是對Document和window兩個對象進行操作,現先把我自己學的Document一些東西和大家分享一下,有什麼問題一定要提出來哦。

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對象

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章