document對象

對象屬性 document.title //設置文檔標題等價於HTML的title標籤html

document.bgColor //設置頁面背景色瀏覽器

document.fgColor //設置前景色(文本顏色)cookie

document.linkColor //未點擊過的連接顏色指針

document.alinkColor //激活連接(焦點在此連接上)的顏色orm

document.vlinkColor //已點擊過的連接顏色htm

document.URL //設置URL屬性從而在同一窗口打開另外一網頁對象

document.fileCreatedDate //文件創建日期,只讀屬性seo

document.fileModifiedDate //文件修改日期,只讀屬性事件

document.fileSize //文件大小,只讀屬性圖片

document.cookie //設置和讀出cookie

document.charset //設置字符集 簡體中文:gb2312

經常使用對象方法

document.write() //動態向頁面寫入內容

document.writeln() -- 在文檔中寫入字符串,並在字符串的末尾增長一個換行符(\n)

document_createElement_x(Tag) //建立一個html標籤對象

document.getElementByIdx_x(ID) //得到指定ID值的對象

document.getElementsByName(Name) //得到指定Name值的對象 document.body.a(oTag)

body-主體子對象 document.body //指定文檔主體的開始和結束等價於body>/body>

document.body.bgColor //設置或獲取對象後面的背景顏色

document.body.link //未點擊過的連接顏色

document.body.alink //激活連接(焦點在此連接上)的顏色

document.body.vlink //已點擊過的連接顏色 document.body.text //文本色

document.body.innerText //設置body>…/body>之間的文本

document.body.innerHTML //設置body>…/body>之間的HTML代碼

document.body.topMargin //頁面上邊距

document.body.leftMargin //頁面左邊距

document.body.rightMargin //頁面右邊距

document.body.bottomMargin //頁面下邊距

document.body.background //背景圖片

document.body.a(oTag) //動態生成一個HTML對象

經常使用對象事件

document.body.onclick=」func()」 //鼠標指針單擊對象是觸發

document.body.onmouseover=」func()」 //鼠標指針移到對象時觸發

document.body.onmouseout=」func()」 //鼠標指針移出對象時觸發

 

selection-選區子對象 document.selection

images集合(頁面中的圖象) a)經過集合引用

document.images //對應頁面上的img標籤

document.images.length //對應頁面上img標籤的個數

document.images[0] //第1個img標籤

document.images[i] //第i-1個img標籤 b)經過nane屬性直接引用 img name=」oImage」 document.images.oImage //document.images.name屬性 c)引用圖片的src屬性

document.images.oImage.src //document.images.name屬性.src d)建立一個圖象 var oImage oImage = new Image() document.images.oImage.src=」1.jpg」 同時在頁面上創建一個img /標籤與之對應就能夠顯示

forms集合(頁面中的表單)

a)經過集合引用 document.forms //對應頁面上的form標籤

document.forms.length //對應頁面上form標籤的個數

document.forms[0] //第1個/form標籤

document.forms[i] //第i-1個/formform標籤

document.forms[i].length //第i-1個/formform中的控件數 d

ocument.forms[i].elements[j] //第i-1個/formform中第j-1個控件

b)經過標籤name屬性直接引用 /formform name=」Myform」>input name=」myctrl」/>/form document.Myform.myctrl //document.表單名.控件名

c)訪問表單的屬性 document.forms[i].name //對應form name>屬性

document.forms[i].action //對應/formform action>屬性

document.forms[i].encoding //對應/formform enctype>屬性 document.forms[i].target //對應/formform target>屬性 document.forms[i].a(oTag) //動態插入一個控件 document.all.oDiv //引用圖層oDiv document.all.oDiv.style.display=」 //圖層設置爲可視 document.all.oDiv.style.display=」none」 //圖層設置爲隱藏

document.getElementId(」oDiv」) //經過getElementId引用對象

document.getElementId(」oDiv」).style=」 document.getElementId(」oDiv」).display=」none」 //document.all表示document中全部對象的集合只有ie支持此屬性,所以也用來判斷瀏覽器的種類

 

document.getElementByIdx_x(」ID」).innerText //動態輸出文本

document.getElementByIdx_x(」ID」).innerHTML //動態輸出HTML

document.getElementByIdx_x(」ID」).outerText //同innerText document.getElementByIdx_x(」ID」).outerHTML //同innerHTML

相關文章
相關標籤/搜索