亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JavaScript window.document的屬性、方法和事件小結(jié)

 更新時(shí)間:2012年10月24日 01:25:16   作者:  
document屬性作為window對(duì)象的一個(gè)子對(duì)象被創(chuàng)建,是用于訪問(wèn)頁(yè)面中所有元素的對(duì)象,這里簡(jiǎn)單整理下,方便學(xué)習(xí)js的朋友

javascript中window.document的屬性、方法和事件的總結(jié),有需要的朋友可參考一下本文章。

屬性:

Attributes 存儲(chǔ)節(jié)點(diǎn)的屬性列表(只讀)
childNodes 存儲(chǔ)節(jié)點(diǎn)的子節(jié)點(diǎn)列表(只讀)
dataType 返回此節(jié)點(diǎn)的數(shù)據(jù)類型
Definition 以DTD或XML模式給出的節(jié)點(diǎn)的定義(只讀)
Doctype 指定文檔類型節(jié)點(diǎn)(只讀)
documentElement 返回文檔的根元素(可讀寫)
firstChild 返回當(dāng)前節(jié)點(diǎn)的第一個(gè)子節(jié)點(diǎn)(只讀)
Implementation 返回XMLDOMImplementation對(duì)象
lastChild 返回當(dāng)前節(jié)點(diǎn)最后一個(gè)子節(jié)點(diǎn)(只讀)
nextSibling 返回當(dāng)前節(jié)點(diǎn)的下一個(gè)兄弟節(jié)點(diǎn)(只讀)
nodeName 返回節(jié)點(diǎn)的名字(只讀)
nodeType 返回節(jié)點(diǎn)的類型(只讀)
nodeTypedValue 存儲(chǔ)節(jié)點(diǎn)值(可讀寫)
nodeValue 返回節(jié)點(diǎn)的文本(可讀寫)
ownerDocument 返回包含此節(jié)點(diǎn)的根文檔(只讀)
parentNode 返回父節(jié)點(diǎn)(只讀)
Parsed 返回此節(jié)點(diǎn)及其子節(jié)點(diǎn)是否已經(jīng)被解析(只讀)
Prefix 返回名稱空間前綴(只讀)
preserveWhiteSpace 指定是否保留空白(可讀寫)
previousSibling 返回此節(jié)點(diǎn)的前一個(gè)兄弟節(jié)點(diǎn)(只讀)
Text 返回此節(jié)點(diǎn)及其后代的文本內(nèi)容(可讀寫)
url 返回最近載入的XML文檔的URL(只讀)
Xml 返回節(jié)點(diǎn)及其后代的XML表示(只讀)

方法:

appendChild 為當(dāng)前節(jié)點(diǎn)添加一個(gè)新的子節(jié)點(diǎn),放在最后的子節(jié)點(diǎn)后
cloneNode 返回當(dāng)前節(jié)點(diǎn)的拷貝
createAttribute 創(chuàng)建新的屬性
createCDATASection 創(chuàng)建包括給定數(shù)據(jù)的CDATA段
createComment 創(chuàng)建一個(gè)注釋節(jié)點(diǎn)
createDocumentFragment 創(chuàng)建DocumentFragment對(duì)象
createElement 創(chuàng)建一個(gè)元素節(jié)點(diǎn)
createEntityReference 創(chuàng)建EntityReference對(duì)象
createNode 創(chuàng)建給定類型,名字和命名空間的節(jié)點(diǎn)
createPorcessingInstruction 創(chuàng)建操作指令節(jié)點(diǎn)
createTextNode 創(chuàng)建包括給定數(shù)據(jù)的文本節(jié)點(diǎn)
getElementsByTagName 返回指定名字的元素集合
hasChildNodes 返回當(dāng)前節(jié)點(diǎn)是否有子節(jié)點(diǎn)
insertBefore 在指定節(jié)點(diǎn)前插入子節(jié)點(diǎn)
Load 導(dǎo)入指定位置的XML文檔
loadXML 導(dǎo)入指定字符串的XML文檔
removeChild 從子結(jié)點(diǎn)列表中刪除指定的子節(jié)點(diǎn)
replaceChild 從子節(jié)點(diǎn)列表中替換指定的子節(jié)點(diǎn)
Save 把XML文件存到指定節(jié)點(diǎn)
selectNodes 對(duì)節(jié)點(diǎn)進(jìn)行指定的匹配,并返回匹配節(jié)點(diǎn)列表
selectSingleNode 對(duì)節(jié)點(diǎn)進(jìn)行指定的匹配,并返回第一個(gè)匹配節(jié)點(diǎn)
transformNode 使用指定的樣式表對(duì)節(jié)點(diǎn)及其后代進(jìn)行轉(zhuǎn)換
transformNodeToObject 使用指定的樣式表將節(jié)點(diǎn)及其后代轉(zhuǎn)換為對(duì)象

body-主體子對(duì)象

document.body //指定文檔主體的開始和結(jié)束等價(jià)于body>/body>
document.body.bgColor //設(shè)置或獲取對(duì)象后面的背景顏色
document.body.link //未點(diǎn)擊過(guò)的鏈接顏色
document.body.alink //激活鏈接(焦點(diǎn)在此鏈接上)的顏色
document.body.vlink //已點(diǎn)擊過(guò)的鏈接顏色
document.body.text //文本色
document.body.innerText //設(shè)置body>…/body>之間的文本
document.body.innerHTML //設(shè)置body>…/body>之間的HTML代碼
document.body.topMargin //頁(yè)面上邊距
document.body.leftMargin //頁(yè)面左邊距
document.body.rightMargin //頁(yè)面右邊距
document.body.bottomMargin //頁(yè)面下邊距
document.body.background //背景圖片

document.body.appendChild(oTag) //動(dòng)態(tài)生成一個(gè)HTML對(duì)象

常用對(duì)象事件

document.body.onclick=”func()” //鼠標(biāo)指針單擊對(duì)象是觸發(fā)
document.body.onmouseover=”func()” //鼠標(biāo)指針移到對(duì)象時(shí)觸發(fā)
document.body.onmouseout=”func()” //鼠標(biāo)指針移出對(duì)象時(shí)觸發(fā)
———————————————————————
location-位置子對(duì)象

document.location.hash // #號(hào)后的部分
document.location.host // 域名+端口號(hào)
document.location.hostname // 域名
document.location.href // 完整URL
document.location.pathname // 目錄部分
document.location.port // 端口號(hào)
document.location.protocol // 網(wǎng)絡(luò)協(xié)議(http:)
document.location.search // ?號(hào)后的部分

documeny.location.reload() //刷新網(wǎng)頁(yè)
document.location.reload(URL) //打開新的網(wǎng)頁(yè)
document.location.assign(URL) //打開新的網(wǎng)頁(yè)
document.location.replace(URL) //打開新的網(wǎng)頁(yè)
———————————————————————
selection-選區(qū)子對(duì)象
document.selection
———————————————————————

images集合(頁(yè)面中的圖象)

a)通過(guò)集合引用
document.images //對(duì)應(yīng)頁(yè)面上的img標(biāo)簽
document.images.length //對(duì)應(yīng)頁(yè)面上img標(biāo)簽的個(gè)數(shù)
document.images[0] //第1個(gè)img標(biāo)簽
document.images[i] //第i-1個(gè)img標(biāo)簽

b)通過(guò)nane屬性直接引用
img name=”oImage”
document.images.oImage //document.images.name屬性

c)引用圖片的src屬性
document.images.oImage.src //document.images.name屬性.src

d)創(chuàng)建一個(gè)圖象
var oImage
oImage = new Image()
document.images.oImage.src=”1.jpg”
同時(shí)在頁(yè)面上建立一個(gè)img /標(biāo)簽與之對(duì)應(yīng)就可以顯示

———————————————————————-

forms集合(頁(yè)面中的表單)

a)通過(guò)集合引用
document.forms //對(duì)應(yīng)頁(yè)面上的form標(biāo)簽
document.forms.length //對(duì)應(yīng)頁(yè)面上/formform標(biāo)簽的個(gè)數(shù)
document.forms[0] //第1個(gè)/formform標(biāo)簽
document.forms[i] //第i-1個(gè)/formform標(biāo)簽
document.forms[i].length //第i-1個(gè)/formform中的控件數(shù)
document.forms[i].elements[j] //第i-1個(gè)/formform中第j-1個(gè)控件

b)通過(guò)標(biāo)簽name屬性直接引用
/formform name=”Myform”>input name=”myctrl”/>/form
document.Myform.myctrl //document.表單名.控件名

c)訪問(wèn)表單的屬性
document.forms[i].name //對(duì)應(yīng)form name>屬性
document.forms[i].action //對(duì)應(yīng)/formform action>屬性
document.forms[i].encoding //對(duì)應(yīng)/formform enctype>屬性
document.forms[i].target //對(duì)應(yīng)/formform target>屬性

document.forms[i].appendChild(oTag) //動(dòng)態(tài)插入一個(gè)控件
document.all.oDiv //引用圖層oDiv
document.all.oDiv.style.display=” //圖層設(shè)置為可視
document.all.oDiv.style.display=”none” //圖層設(shè)置為隱藏
document.getElementId(”oDiv”) //通過(guò)getElementId引用對(duì)象
document.getElementId(”oDiv”).style=”
document.getElementId(”oDiv”).display=”none”
/*document.all表示document中所有對(duì)象的集合
只有ie支持此屬性,因此也用來(lái)判斷瀏覽器的種類*/

圖層對(duì)象的4個(gè)屬性
document.getElementById(”ID”).innerText //動(dòng)態(tài)輸出文本
document.getElementById(”ID”).innerHTML //動(dòng)態(tài)輸出HTML
document.getElementById(”ID”).outerText //同innerText
document.getElementById(”ID”).outerHTML //同innerHTML

document屬性作為window對(duì)象的一個(gè)子對(duì)象被創(chuàng)建,是用于訪問(wèn)頁(yè)面中所有元素的對(duì)象。其主要具有以下一些應(yīng)用特性:

屬性/方法/事件 描述
onClick 當(dāng)文檔被點(diǎn)擊時(shí)觸發(fā)
onDblClick 當(dāng)文檔被雙擊時(shí)觸發(fā)
onKeyDown 當(dāng)按下任意鍵時(shí)觸發(fā)。優(yōu)先于onKeyPress事件觸發(fā)器
onKeyPress 參見onKeyDown
onKeyUp 當(dāng)釋放按下的鍵時(shí)觸發(fā)
onMouseDown 當(dāng)按下鼠標(biāo)鍵時(shí)觸發(fā)
onMouseUp 當(dāng)釋放鼠標(biāo)鍵時(shí)觸發(fā)
captureEvents() 捕獲所有與文檔相關(guān)的事件
close() 關(guān)閉文檔流
getSelection() 返回當(dāng)前選中的文本
handleEvent() 調(diào)用事件處理器給指定的事件
open() 打開文檔流
releaseEvents() 釋放所捕獲的事件
routeEvent() 通過(guò)正常的處理程序來(lái)傳遞所捕獲的事件
write() 向文檔中寫入內(nèi)容
writeln() 在文檔中寫入帶有換行符的字符串
alinkColor 指定相關(guān)標(biāo)簽的alink屬性
anchors 包含了文檔中所有anchor標(biāo)簽的數(shù)組
bgColor 指定相關(guān)標(biāo)簽的背景顏色。
cookie 指定cookie
domain 指定服務(wù)于文檔的域
embeds 包含了文檔中所有embed標(biāo)簽的數(shù)組
fgColor 指定相關(guān)標(biāo)簽的text屬性
formName 文檔中每個(gè)form的實(shí)際名稱
forms 包含了文檔中所有form標(biāo)簽的數(shù)組
images 包含了文檔中所有image標(biāo)簽的數(shù)組
lastModified 指定文檔最后更改的日期
layers 包含了文檔中l(wèi)ayer的所有標(biāo)簽的數(shù)組
linkColor 指定相關(guān)標(biāo)簽的link屬性
links 包含了文檔中所有l(wèi)inks的數(shù)組
plugins 包含了文檔中所有plug-in的數(shù)組
referrer 指定referral URL.
title 標(biāo)題文字
URL 指定文檔的URL
vlinkColor 指定相關(guān)標(biāo)簽的vlink屬性

相關(guān)文章

最新評(píng)論