ÍøÂçѧԺ w3popÉçÇø ÍøÂç×ÊÔ´ ITÐÂÎÅ

w3pop.com :: ÍøÂçѧԺ :: HTML DOM :: DOM Document ¶ÔÏó

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

HTML DOM
DOM TableRow ¶ÔÏ..
DOM Textarea ¶ÔÏ..
DOM Window ¶ÔÏó

DOM Document ¶ÔÏó


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ä¯ÀÀ:13407 :: ::

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
ÃèÊö
IE F N W3C
anchors[] Returns a reference to all Anchor objects in the document
ÂÞÁÐdocumentÖÐËùÓÐAnchor¶ÔÏóµÄ²Î¿¼
3 1 2 Yes
applets[] Returns a reference to all Applet objects in the document
·µ»ØÔÚÎĵµÖÐËùÓÐApplet¶ÔÏóµÄ²Î¿¼
4 1 3 Yes
attributes[]   - 1 6 No
childNodes[]   5 1 6 No
embeds[] Returns a reference to all embedded objects in the document
·µ»ØÔÚÎĵµÀïËùÓÐǶÈë¶ÔÏóµÄ²Î¿¼
4 1 3 No
forms[] Returns a reference to all Form objects in the document
ÂÞÁÐdocumentÖÐËùÓÐ±íµ¥¶ÔÏóµÄ²Î¿¼
3 1 2 Yes
images[] Returns a reference to all Image objects in the document
ÂÞÁÐdocumentÖÐËùÓÐimage¶ÔÏóµÄ²Î¿¼
4 1 3 Yes
links[] Returns a reference to all Link objects in the document
·µ»ØÔÚÎĵµÖÐËùÓÐlink¶ÔÏóµÄ²Î¿¼
3 1 2 Yes
plugins[]   - 1 6 No
stylesheets[]   5 1 6 No

Document Object Properties(¶ÔÏóÊôÐÔ)

Property
ÊôÐÔ
Description
ÃèÊö
IE F N W3C
alinkColor Sets or returns the color of the active links in the document
ÉèÖûò·µ»ØÔÚÎĵµÖлÁ¬½ÓµÄÑÕÉ«
3 1 2 D
bgColor Sets or returns the background-color of the document
ÉèÖûò·µ»ØÎĵµ±³¾°ÑÕÉ«
3 1 2 D
body Specifies the beginning and end of the document body
Ö¸¶¨ÎĵµbodyµÄ¿ªÍ·ºÍ½áβ
5 1 6 Yes
cookie Sets or returns all cookies associated with the document
ͨ¹ýdocumentÉèÖûò·µ»ØËùÓÐÓйØÎĵµµÄcookies
3 1 2 Yes
documentElement Returns a reference to the root node of the document
·µ»ØÎĵµ¸ù²¿½ÚµãµÄ²Î¿¼
5 1 6 No
domain Returns the document server's domain name
·µ»ØÎĵµµÄ·þÎñÆ÷ÓòÃû
4 1 3 Yes
fgColor Sets or returns the text-color of the document
ÉèÖûò·µ»ØÎĵµµÄÎÄ×ÖÑÕÉ«
3 1 2 D
lastModified Returns the date and time the document was last modified
·µ»ØÎĵ²×îºóÐ޸ĵÄÈÕÆÚ
3 1 2 No
linkColor Sets or returns the color of the links in the document
ÉèÖûò·µ»ØÎĵµÖÐÁ¬½ÓµÄÑÕÉ«
3 1 2 D
referrer Returns the URL of the document that loaded the current document
·µ»Ø±»Ö±½Ó¼ÓÔØµÄÎĵµURL
3 1 2 Yes
title Returns the title of the document
·µ»ØÎĵµµÄ±êÌâ
3 1 2 Yes
URL Returns the URL of the current document
·µ»Øµ±Ç°ÎĵµµÄURL
4 1 3 Yes
vlinkColor Sets or returns the color of the visited links in the document
ÉèÖûò·µ»ØÎĵµÖзÃÎʹýÁ¬½ÓµÄÑÕÉ«
3 1 2 D

Document Object Methods¶ÔÏó·½·¨

Method
·½·¨
Description
ÃèÊö
IE F N W3C
clear() Clears all elements in the document
Çå¿ÕËùÓÐÎĵµÖеÄÔªËØ
- 1 2 No
close() Closes the output stream and displays the sent data
¹Ø±ÕÊä³öÁ÷ÒÔ¼°·¢ËÍÊý¾ÝµÄÏÔʾ
3 1 2 Yes
createAttribute("name") Creates an attribute with a specified name
½¨Á¢Ö¸¶¨nameµÄÊôÐÔ
6 1 6 No
createElement("tag") Creates an element
½¨Á¢ÔªËØ
5 1 6 Yes
createTextNode("txt") Creates a text string
½¨Á¢ÎÄ×Ö´®
5 1 6 Yes
focus() Gives the document focus
Îĵµ¾Û½¹
5 1 6 No
getElementById() Returns a reference to the first object with the specified ID
ͨ¹ýÖ¸¶¨ID·µ»ØµÚÒ»¸ö·ûºÏ¶ÔÏóµÄ²Î¿¼
5 1 6 Yes
getElementsByName() Returns a collection of objects with the specified NAME
ͨ¹ýÖ¸¶¨NAME·µ»Ø·ûºÏµÄ¶ÔÏ󼯺Ï
5 1 6 Yes
getElementsByTagName("tag") Returns a collection of objects with the specified TAGNAME
ͨ¹ýÖ¸¶¨TAGNAME·µ»Ø·ûºÏµÄ¶ÔÏó
5 1 6 No
open() Opens a document for writing
ΪдÈë´ò¿ªÒ»·ÝÎĵµ
3 1 2 Yes
write() Writes a text string to a document
ÔÚÎĵµÖÐдÈëÎÄ×Ö´®
3 1 2 Yes
writeln("str") Writes a text string followed by a new line character to a document opened by open()
ÐÂÐÐдÈë
3 1 2 Yes

Document Object Events¶ÔÏóʼþ

Syntax: document.event_name="someJavaScriptCode"

Event
ʼþ
Description
ÃèÊö
IE F N W3C
onClick Executes some code when a Click event occurs
µ±µã»÷ʼþ·¢ÉúµÄʱºòÖ´ÐÐһЩ´úÂë
5 1 6  
onDblClick Executes some code when a Doubleclick event occurs
µ±Ë«»÷ʼþ·¢ÉúµÄʱºòÖ´ÐÐһЩ´úÂë
5 1 6  
onFocus Executes some code when a Focus event occurs
µ±¾Û½¹Ê¼þ·¢ÉúµÄʱºòÖ´ÐÐһЩ´úÂë
5 1 6  
onKeyDown Executes some code when a Keydown event occurs
µ±¼ü°´×¡Ê¼þ·¢ÉúʱִÐÐһЩ´úÂë
5 1 6  
onKeyPress Executes some code when a Keypress event occurs
µ±¼ü°´ÏÂʼþ·¢Éú¾ÍÖ´ÐÐһЩ´úÂë
5 1 6  
onKeyUp Executes some code when a Keyup event occurs
µ±Ìá¼üʼþ·¢Éú¾ÍÖ´ÐдúÂë
5 1 6  
onMouseDown Executes some code when a Mousedown event occurs
µ±Êó±ê°´×¡Ê¼þ·¢Éú¾ÍÖ´ÐдúÂë
5 1 6  
onMouseMove Executes some code when a Mousemove event occurs
µ±Êó±êÒÆ¶¯Ê¼þ·¢Éú¾ÍÖ´ÐдúÂë
5 1 6  
onMouseOut Executes some code when a Mouseout event occurs
µ±Êó±êÀ뿪ʼþ·¢Éú¾ÍÖ´ÐÐһЩ´úÂë
5 1 6  
onMouseOver Executes some code when a Mouseover event occurs
µ±Êó±êÒÆµ½ÉÏ·½Ê¼þ·¢Éú¾ÍÖ´ÐдúÂë
5 1 6  
onMouseUp Executes some code when a Mouseup event occurs
µ½Êó±êÊͷžÍÖ´ÐдúÂë
5 1 6  
onResize Executes some code when a Resize event occurs
µ±¸Ä±ä´óСʼþ·¢Éú¾ÍÖ´ÐдúÂë
5 1 6  

ÆÀÂÛ (3) 1 All