DOM Document 对象

Document Object
Document 对象

The Document object represents the entire HTML document and can be used to access all elements in a page.
Document对象代表着整个HTML文档并可以用来访问所有页面中的元素。

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard), D: Deprecated.

Document Object Collections(对象集合)

Collection
集合
Description
描述
IEFNW3C
anchors[]Returns a reference to all Anchor objects in the document
罗列document中所有Anchor对象的参考
312Yes
applets[]Returns a reference to all Applet objects in the document
返回在文档中所有Applet对象的参考
413Yes
attributes[] -16No
childNodes[] 516No
embeds[]Returns a reference to all embedded objects in the document
返回在文档里所有嵌入对象的参考
413No
forms[]Returns a reference to all Form objects in the document
罗列document中所有表单对象的参考
312Yes
images[]Returns a reference to all Image objects in the document
罗列document中所有image对象的参考
413Yes
links[]Returns a reference to all Link objects in the document
返回在文档中所有link对象的参考
312Yes
plugins[] -16No
stylesheets[] 516No

Document Object Properties(对象属性)

Property
属性
Description
描述
IEFNW3C
alinkColorSets or returns the color of the active links in the document
设置或返回在文档中活动连接的颜色
312D
bgColorSets or returns the background-color of the document
设置或返回文档背景颜色
312D
bodySpecifies the beginning and end of the document body
指定文档body的开头和结尾
516Yes
cookieSets or returns all cookies associated with the document
通过document设置或返回所有有关文档的cookies
312Yes
documentElementReturns a reference to the root node of the document
返回文档根部节点的参考
516No
domainReturns the document server's domain name
返回文档的服务器域名
413Yes
fgColorSets or returns the text-color of the document
设置或返回文档的文字颜色
312D
lastModifiedReturns the date and time the document was last modified
返回文挡最后修改的日期
312No
linkColorSets or returns the color of the links in the document
设置或返回文档中连接的颜色
312D
referrerReturns the URL of the document that loaded the current document
返回被直接加载的文档URL
312Yes
titleReturns the title of the document
返回文档的标题
312Yes
URLReturns the URL of the current document
返回当前文档的URL
413Yes
vlinkColorSets or returns the color of the visited links in the document
设置或返回文档中访问过连接的颜色
312D

Document Object Methods对象方法

Method
方法
Description
描述
IEFNW3C
clear()Clears all elements in the document
清空所有文档中的元素
-12No
close()Closes the output stream and displays the sent data
关闭输出流以及发送数据的显示
312Yes
createAttribute("name")Creates an attribute with a specified name
建立指定name的属性
616No
createElement("tag")Creates an element
建立元素
516Yes
createTextNode("txt")Creates a text string
建立文字串
516Yes
focus()Gives the document focus
文档聚焦
516No
getElementById()Returns a reference to the first object with the specified ID
通过指定ID返回第一个符合对象的参考
516Yes
getElementsByName()Returns a collection of objects with the specified NAME
通过指定NAME返回符合的对象集合
516Yes
getElementsByTagName("tag")Returns a collection of objects with the specified TAGNAME
通过指定TAGNAME返回符合的对象
516No
open()Opens a document for writing
为写入打开一份文档
312Yes
write()Writes a text string to a document
在文档中写入文字串
312Yes
writeln("str")Writes a text string followed by a new line character to a document opened by open()
新行写入
312Yes

Document Object Events对象事件

Syntax: document.event_name="someJavaScriptCode"

Event
事件
Description
描述
IEFNW3C
onClickExecutes some code when a Click event occurs
当点击事件发生的时候执行一些代码
516 
onDblClickExecutes some code when a Doubleclick event occurs
当双击事件发生的时候执行一些代码
516 
onFocusExecutes some code when a Focus event occurs
当聚焦事件发生的时候执行一些代码
516 
onKeyDownExecutes some code when a Keydown event occurs
当键按住事件发生时执行一些代码
516 
onKeyPressExecutes some code when a Keypress event occurs
当键按下事件发生就执行一些代码
516 
onKeyUpExecutes some code when a Keyup event occurs
当提键事件发生就执行代码
516 
onMouseDownExecutes some code when a Mousedown event occurs
当鼠标按住事件发生就执行代码
516 
onMouseMoveExecutes some code when a Mousemove event occurs
当鼠标移动事件发生就执行代码
516 
onMouseOutExecutes some code when a Mouseout event occurs
当鼠标离开事件发生就执行一些代码
516 
onMouseOverExecutes some code when a Mouseover event occurs
当鼠标移到上方事件发生就执行代码
516 
onMouseUpExecutes some code when a Mouseup event occurs
到鼠标释放就执行代码
516 
onResizeExecutes some code when a Resize event occurs
当改变大小事件发生就执行代码
516 
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值