ȨÆäÀÌÁöÁ¦ÀÛ±³½Ç
ȨÆäÀÌÁö Á¦ÀÛ±âÃÊ
±âº»Å±×
ÅÂ±×ÆÁ¸ðÀ½
ű×ÀÚ·á¹æ
Æ÷Åä¼¥°ÁÂ
À¥.°ü·Ã°ÁÂ
PHP°ÁÂ
PHPÆÁ
HTML.CSS
JAVASCRIPT
ASP
JSP
PHP½ÉÈ
C.C++
Ç÷¡½Ã.ActionScript
ÀÚÀ¯°Ô½ÃÆÇ
Áú¹®°Ô½ÃÆÇ
À¯¸Ó°Ô½ÃÆÇ
¿À¶ô½Ç
Tel. 042-353-2371
ÆòÀÏ ¿ÀÀü 9½Ã ~ ¿ÀÈÄ 7½Ã
±â¾÷ÀºÇà
010-8649-6758
¿¹±ÝÁÖ:Á¦ÁÖ»ç¶û(¼ÛÁø¾Æ)
JAVASCRIPT
Ȩ > ȨÆäÀÌÁöÁ¦ÀÛ±³½Ç > JAVASCRIPT
ÀÛ¼ºÀÚ
freewebkorea
Ä«Å×°í¸®
JavaScript
Tutorial
Object
ºñ¹Ð¹øÈ£
Á¦¸ñ
<H2>Document Object</H2> <P class=mtext>ÀÌ ¹ø ÆäÀÌÁö¿¡¼´Â Document °´Ã¼°¡ °¡Áö°í ÀÖ´Â Property(ÇÏÀ§ °´Ã¼)µé¿¡ ´ëÇØ¼ ¾Ë¾Æ º¸µµ·Ï ÇϰڽÀ´Ï´Ù. Document °´Ã¼ÀÇ PropertyµéÀº ÁÖ·Î ¹®¼(Document)³»ÀÇ Link, Anchor, Image, Title µî ¹®¼¿¡ »ç¿ëµÈ Tag¿¡ ´ëÇÑ ¹®¼ ³»ºÎÀûÀÎ Á¤º¸¿Í ¹®¼ÀÇ domain, Url µî ¿ÜºÎÀûÀÎ Á¤º¸¿Í Á¤º¸ µéÀ» ¾Ë¾Æ º¸´Âµ¥ »ç¿ëµÇ¸ç ¾Æ·¡ÀÇ ±×¸²¿¡¼ º¸´Â ¹Ù¿Í °°ÀÌ document °´Ã¼¿¡´Â ¿©·¯ °³ÀÇ ÇÏÀ§ °´Ã¼µéÀÌ ÀÖÀ¸¸ç, Layer¿Í PluginÀº Netscape¿¡¼¸¸ Àû¿ëµË´Ï´Ù.<BR><BR><B style="COLOR: #941919">*** Property¿Í Method À̸§Àº ´ë¼Ò¹®ÀÚ¸¦ Çо¾¸® ±¸ºÐ(Case-sensitive)ÇÕ´Ï´Ù.</B> </P><IMG oncontextmenu="return false" alt="browser_inner_object (13K)" src="http://www.cadvance.org/doc/java/images/browser_inner_object.gif"> <TABLE class=attributeTbl cellSpacing=2 cellPadding=0 border=0> <TBODY> <TR> <TD class=titleCell colSpan=2>Document Object Properties</TD></TR> <COLGROUP> <COL class=syntaxLeftCell> <COL class=syntaxRightCell> <TBODY> <TR> <TD>anchors</TD> <TD>¹®¼¿¡ Æ÷ÇÔµÈ anchor element collection return</TD></TR> <TR> <TD>applets</TD> <TD>applet ¿¡ Æ÷ÇÔµÈ ¸ðµç element collection return</TD></TR> <TR> <TD>body</TD> <TD>body ¶Ç´Â frameset return</TD></TR> <TR> <TD>cookie</TD> <TD>¹®¼ÀÇ ÄíŰ °ª return</TD></TR> <TR> <TD>domain</TD> <TD>¹®¼ÀÇ µµ¸ÞÀÎ À̸§ return</TD></TR> <TR> <TD>forms</TD> <TD>¹®¼ÀÇ form collection¿¡ Æ÷ÇÔµÈ ¸ðµç element return</TD></TR> <TR> <TD>images</TD> <TD>¹®¼¿¡ Æ÷ÇÔµÈ ¸ðµç image element collection return</TD></TR> <TR> <TD>links</TD> <TD>¹®¼³»ÀÇ href attribute·Î ÁöÁ¤µÈ ¸ðµç anchor collection return</TD></TR> <TR> <TD>referrer</TD> <TD>ÇöÀç ¹®¼ÀÇ ¸µÅ©°¡ ÀÖ´Â ¹®¼ÀÇ URL °ª return</TD></TR> <TR> <TD>title</TD> <TD>¹®¼ÀÇ title return ¶Ç´Â ÁöÁ¤</TD></TR> <TR> <TD>URL</TD> <TD>¹®¼ÀÇ URL °ª return</TD></TR></TBODY></TABLE><BR><BR><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>Document ObjectÀÇ Property ¿¹Á¦</B> <PRE class=input id=document_property><html> <head> <title>Document ObjectÀÇ Property</title> <style type="text/css"> <!-- img {border:1px solid royalblue;} --> </style> </head> <body style="background-color:buttonface;"> <fieldset style="padding:10px;"> <legend>Document ObjectÀÇ Property</legend> <a name="first">first</a><br /> <a name="second">second</a><br /> <a name="third">third</a><br /> <form name="frm1"><input value="form1" /></form><br /> <form name="frm2"><input value="form2" /></form> <img src="../../images/icon/ico_doc.gif" alt="ico_doc (1K)" /><br /><br /> <img src="../../images/icon/ico_doc_new.gif" alt="ico_doc_new (1K)" /><br /><br /> <img src="../../images/icon/ico_explanation.gif" alt="ico_explanation (1K)" /><br /><br /> <a href="#first">link 1</a><br /> <a href="#second" id="link2">link 2</a><br /> <a href="#third">link 3</a><br /> </fieldset><br /><br /> <script type="text/javascript"> <!-- document.write("¹®¼ÀÇ ¹è°æ»ö : " + document.<B>body</B>.style.backgroundColor + "<br />") document.write("¹®¼ÀÇ Á¦¸ñ : " + document.<B>title</B> + "<br />") document.write("¹®¼¿¡ Æ÷ÇÔµÈ anchorÀÇ °¹¼ö : " + document.<B>anchors</B>.length + "°³<br />") document.write("¹®¼¿¡ Æ÷ÇÔµÈ Ã¹¹øÂ° anchorÀ̸§ : " + document.<B>anchors[0]</B>.name + "<br/>") document.write("¹®¼¿¡ Æ÷ÇÔµÈ linkÀÇ °¹¼ö : " + document.<B>links</B>.length + "°³<br />") document.write("¹®¼¿¡ Æ÷ÇÔµÈ µÎ¹øÂ° linkÀÇ id : " + document.<B>links[1]</B>.id + "<br />") document.write("¹®¼¿¡ Æ÷ÇÔµÈ imageÀÇ °¹¼ö : " + document.<B>images</B>.length + "°³<br />") document.write("¹®¼ÀÇ URL : " + document.<B>URL</B> + "<br />") document.write("¹®¼¿¡ Æ÷ÇÔµÈ formÀÇ °¹¼ö : " + document.<B>forms</B>.length + "°³<br />") document.write("¹®¼ÀÇ Ã¹ ¹øÂ° formÀÇ name °ª : " + document.<B>forms[0]</B>.name + "<br />") document.write("¹®¼ÀÇ µÎ ¹øÂ° formÀÇ name °ª : " + document.<B>forms[1]</B>.name + "<br />") document.write("ÀÌ ¹®¼ÀÇ Link°¡ ÀÖ´Â fileÀÇ URL : " + document.<B>referrer</B> + "<br />") document.write("¹®¼ÀÇ cookie °ª : " + document.<B>cookie</B> + "<br />") document.write("¹®¼ÀÇ Domain name : " + document.<B>domain</B> + "<br />") // --> </script> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(document_property);open_window('../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR> <HR class=grayHr> <BR><B>Document object ÀÇ Method</B> <P class=mtext>¾î¶² Object¿¡ °ü·ÃÇØ¼ Method ¶ó´Â°Ô ¿©·¯°³ ÀÖ½À´Ï´Ù. Method¶õ ´Ü¾îÀÇ ¶æ ó·³ ±× ÇØ´ç Object¸¦ ´Ù·ç´Â ¹æ¹ýÀÌ µÇ°Ú½À´Ï´Ù. ±×·¯¹Ç·Î Document Object¿¡ °ü·ÃµÈ Method´Â °ð Document Object¸¦ ´Ù·ç´Â ¹æ¹ýÀ¸·Î¼ ÀÌ·¯ÇÑ MethodµéÀº ºê¶ó¿ìÀú°¡ Áö¿øÇÏ°Ô µË´Ï´Ù. ¾Æ·¡ÀÇ Ç¥´Â Document Object¸¦ ´Ù·ç´Â Method°¡ µÇ°Ú½À´Ï´Ù.</P> <TABLE class=attributeTbl cellSpacing=2 cellPadding=0 border=0> <TBODY> <TR> <TD class=titleCell colSpan=2>Document Object Methods</TD></TR> <COLGROUP> <COL class=syntaxLeftCell> <COL class=syntaxRightCell> <TBODY> <TR> <TD>close()</TD> <TD>document.open() method·Î ¿¸° ¹®¼¸¦ ´Ý´Â´Ù.</TD></TR> <TR> <TD>getElementById(<I><FONT color=#941919>ID</FONT></I>)</TD> <TD>ÁöÁ¤µÈ ID ¸¦ °¡Áø element return</TD></TR> <TR> <TD>getElementsByName(<I><FONT color=#941919>name</FONT></I>)</TD> <TD>ÁöÁ¤µÈ name ¸¦ °¡Áø element return</TD></TR> <TR> <TD>open()</TD> <TD>»õ ¹®¼¸¦ ¿¬´Ù.</TD></TR> <TR> <TD>write(<I><FONT color=#941919>string</FONT></I>)</TD> <TD>¹®¼¿¡ ¹®ÀÚ¿À» Ãâ·ÂÇÑ´Ù.</TD></TR> <TR> <TD>writeln(<I><FONT color=#941919>string</FONT></I>)</TD> <TD>¹®¼¿¡ ¹®ÀÚ¿ blockÀ» Ãâ·ÂÇÑ´Ù.</TD></TR></TBODY></TABLE><BR><BR><!-- ÀÔ·Â pre ½ÃÀÛ --><STRONG>getElementById("</STRONG><I><FONT color=#941919>ID</FONT></I><STRONG>") & getElementsByName("</STRONG><I><FONT color=#941919>name</FONT></I><STRONG>") Method</STRONG> <PRE class=input id=id_name><html> <head> <script type="text/javascript"> <!-- function <B>getElement</B>() { var doc=document.<B>getElementById</B>("<B>myPara</B>") alert("³ªÀÇ À̸§Àº " + doc.<B>tagName</B> + " element ÀÔ´Ï´Ù. ") } function <B>getName</B>() { var doc=document.<B>getElementsByName</B>("<B>myName</B>") alert("¸ðµÎ " + doc.<B>length</B> + " °³ ÀÔ´Ï´Ù. ") } //--> </script> </head> <body> <button id="<B>myPara</B>" onclick="<B>getElement</B>()"> Ŭ¸¯ÇÏ¸é ³ªÀÇ Element À̸§ÀÌ ³ª¿É´Ï´Ù. </button><br /> <input name="<B>myName</B>" /><br /> <input name="<B>myName</B>" /><br /> <input name="<B>myName</B>" /><br /> <button onclick="<B>getName</B>()">Ŭ¸¯Çϸé ElementÀÇ °¹¼ö°¡ ³ª¿É´Ï´Ù.</button> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(id_name);open_window('../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR><BR> <HR class=blackHr>
<H2>Document Object</H2> <P class=mtext>ÀÌ ¹ø ÆäÀÌÁö¿¡¼´Â Document °´Ã¼°¡ °¡Áö°í ÀÖ´Â Property(ÇÏÀ§ °´Ã¼)µé¿¡ ´ëÇØ¼ ¾Ë¾Æ º¸µµ·Ï ÇϰڽÀ´Ï´Ù. Document °´Ã¼ÀÇ PropertyµéÀº ÁÖ·Î ¹®¼(Document)³»ÀÇ Link, Anchor, Image, Title µî ¹®¼¿¡ »ç¿ëµÈ Tag¿¡ ´ëÇÑ ¹®¼ ³»ºÎÀûÀÎ Á¤º¸¿Í ¹®¼ÀÇ domain, Url µî ¿ÜºÎÀûÀÎ Á¤º¸¿Í Á¤º¸ µéÀ» ¾Ë¾Æ º¸´Âµ¥ »ç¿ëµÇ¸ç ¾Æ·¡ÀÇ ±×¸²¿¡¼ º¸´Â ¹Ù¿Í °°ÀÌ document °´Ã¼¿¡´Â ¿©·¯ °³ÀÇ ÇÏÀ§ °´Ã¼µéÀÌ ÀÖÀ¸¸ç, Layer¿Í PluginÀº Netscape¿¡¼¸¸ Àû¿ëµË´Ï´Ù.<BR><BR><B style="COLOR: #941919">*** Property¿Í Method À̸§Àº ´ë¼Ò¹®ÀÚ¸¦ Çо¾¸® ±¸ºÐ(Case-sensitive)ÇÕ´Ï´Ù.</B> </P><IMG oncontextmenu="return false" alt="browser_inner_object (13K)" src="http://www.cadvance.org/doc/java/images/browser_inner_object.gif"> <TABLE class=attributeTbl cellSpacing=2 cellPadding=0 border=0> <TBODY> <TR> <TD class=titleCell colSpan=2>Document Object Properties</TD></TR> <COLGROUP> <COL class=syntaxLeftCell> <COL class=syntaxRightCell> <TBODY> <TR> <TD>anchors</TD> <TD>¹®¼¿¡ Æ÷ÇÔµÈ anchor element collection return</TD></TR> <TR> <TD>applets</TD> <TD>applet ¿¡ Æ÷ÇÔµÈ ¸ðµç element collection return</TD></TR> <TR> <TD>body</TD> <TD>body ¶Ç´Â frameset return</TD></TR> <TR> <TD>cookie</TD> <TD>¹®¼ÀÇ ÄíŰ °ª return</TD></TR> <TR> <TD>domain</TD> <TD>¹®¼ÀÇ µµ¸ÞÀÎ À̸§ return</TD></TR> <TR> <TD>forms</TD> <TD>¹®¼ÀÇ form collection¿¡ Æ÷ÇÔµÈ ¸ðµç element return</TD></TR> <TR> <TD>images</TD> <TD>¹®¼¿¡ Æ÷ÇÔµÈ ¸ðµç image element collection return</TD></TR> <TR> <TD>links</TD> <TD>¹®¼³»ÀÇ href attribute·Î ÁöÁ¤µÈ ¸ðµç anchor collection return</TD></TR> <TR> <TD>referrer</TD> <TD>ÇöÀç ¹®¼ÀÇ ¸µÅ©°¡ ÀÖ´Â ¹®¼ÀÇ URL °ª return</TD></TR> <TR> <TD>title</TD> <TD>¹®¼ÀÇ title return ¶Ç´Â ÁöÁ¤</TD></TR> <TR> <TD>URL</TD> <TD>¹®¼ÀÇ URL °ª return</TD></TR></TBODY></TABLE><BR><BR><!-- ÀÔ·Â pre ½ÃÀÛ --><B class=pos>Document ObjectÀÇ Property ¿¹Á¦</B> <PRE class=input id=document_property><html> <head> <title>Document ObjectÀÇ Property</title> <style type="text/css"> <!-- img {border:1px solid royalblue;} --> </style> </head> <body style="background-color:buttonface;"> <fieldset style="padding:10px;"> <legend>Document ObjectÀÇ Property</legend> <a name="first">first</a><br /> <a name="second">second</a><br /> <a name="third">third</a><br /> <form name="frm1"><input value="form1" /></form><br /> <form name="frm2"><input value="form2" /></form> <img src="../../images/icon/ico_doc.gif" alt="ico_doc (1K)" /><br /><br /> <img src="../../images/icon/ico_doc_new.gif" alt="ico_doc_new (1K)" /><br /><br /> <img src="../../images/icon/ico_explanation.gif" alt="ico_explanation (1K)" /><br /><br /> <a href="#first">link 1</a><br /> <a href="#second" id="link2">link 2</a><br /> <a href="#third">link 3</a><br /> </fieldset><br /><br /> <script type="text/javascript"> <!-- document.write("¹®¼ÀÇ ¹è°æ»ö : " + document.<B>body</B>.style.backgroundColor + "<br />") document.write("¹®¼ÀÇ Á¦¸ñ : " + document.<B>title</B> + "<br />") document.write("¹®¼¿¡ Æ÷ÇÔµÈ anchorÀÇ °¹¼ö : " + document.<B>anchors</B>.length + "°³<br />") document.write("¹®¼¿¡ Æ÷ÇÔµÈ Ã¹¹øÂ° anchorÀ̸§ : " + document.<B>anchors[0]</B>.name + "<br/>") document.write("¹®¼¿¡ Æ÷ÇÔµÈ linkÀÇ °¹¼ö : " + document.<B>links</B>.length + "°³<br />") document.write("¹®¼¿¡ Æ÷ÇÔµÈ µÎ¹øÂ° linkÀÇ id : " + document.<B>links[1]</B>.id + "<br />") document.write("¹®¼¿¡ Æ÷ÇÔµÈ imageÀÇ °¹¼ö : " + document.<B>images</B>.length + "°³<br />") document.write("¹®¼ÀÇ URL : " + document.<B>URL</B> + "<br />") document.write("¹®¼¿¡ Æ÷ÇÔµÈ formÀÇ °¹¼ö : " + document.<B>forms</B>.length + "°³<br />") document.write("¹®¼ÀÇ Ã¹ ¹øÂ° formÀÇ name °ª : " + document.<B>forms[0]</B>.name + "<br />") document.write("¹®¼ÀÇ µÎ ¹øÂ° formÀÇ name °ª : " + document.<B>forms[1]</B>.name + "<br />") document.write("ÀÌ ¹®¼ÀÇ Link°¡ ÀÖ´Â fileÀÇ URL : " + document.<B>referrer</B> + "<br />") document.write("¹®¼ÀÇ cookie °ª : " + document.<B>cookie</B> + "<br />") document.write("¹®¼ÀÇ Domain name : " + document.<B>domain</B> + "<br />") // --> </script> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(document_property);open_window('../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR> <HR class=grayHr> <BR><B>Document object ÀÇ Method</B> <P class=mtext>¾î¶² Object¿¡ °ü·ÃÇØ¼ Method ¶ó´Â°Ô ¿©·¯°³ ÀÖ½À´Ï´Ù. Method¶õ ´Ü¾îÀÇ ¶æ ó·³ ±× ÇØ´ç Object¸¦ ´Ù·ç´Â ¹æ¹ýÀÌ µÇ°Ú½À´Ï´Ù. ±×·¯¹Ç·Î Document Object¿¡ °ü·ÃµÈ Method´Â °ð Document Object¸¦ ´Ù·ç´Â ¹æ¹ýÀ¸·Î¼ ÀÌ·¯ÇÑ MethodµéÀº ºê¶ó¿ìÀú°¡ Áö¿øÇÏ°Ô µË´Ï´Ù. ¾Æ·¡ÀÇ Ç¥´Â Document Object¸¦ ´Ù·ç´Â Method°¡ µÇ°Ú½À´Ï´Ù.</P> <TABLE class=attributeTbl cellSpacing=2 cellPadding=0 border=0> <TBODY> <TR> <TD class=titleCell colSpan=2>Document Object Methods</TD></TR> <COLGROUP> <COL class=syntaxLeftCell> <COL class=syntaxRightCell> <TBODY> <TR> <TD>close()</TD> <TD>document.open() method·Î ¿¸° ¹®¼¸¦ ´Ý´Â´Ù.</TD></TR> <TR> <TD>getElementById(<I><FONT color=#941919>ID</FONT></I>)</TD> <TD>ÁöÁ¤µÈ ID ¸¦ °¡Áø element return</TD></TR> <TR> <TD>getElementsByName(<I><FONT color=#941919>name</FONT></I>)</TD> <TD>ÁöÁ¤µÈ name ¸¦ °¡Áø element return</TD></TR> <TR> <TD>open()</TD> <TD>»õ ¹®¼¸¦ ¿¬´Ù.</TD></TR> <TR> <TD>write(<I><FONT color=#941919>string</FONT></I>)</TD> <TD>¹®¼¿¡ ¹®ÀÚ¿À» Ãâ·ÂÇÑ´Ù.</TD></TR> <TR> <TD>writeln(<I><FONT color=#941919>string</FONT></I>)</TD> <TD>¹®¼¿¡ ¹®ÀÚ¿ blockÀ» Ãâ·ÂÇÑ´Ù.</TD></TR></TBODY></TABLE><BR><BR><!-- ÀÔ·Â pre ½ÃÀÛ --><STRONG>getElementById("</STRONG><I><FONT color=#941919>ID</FONT></I><STRONG>") & getElementsByName("</STRONG><I><FONT color=#941919>name</FONT></I><STRONG>") Method</STRONG> <PRE class=input id=id_name><html> <head> <script type="text/javascript"> <!-- function <B>getElement</B>() { var doc=document.<B>getElementById</B>("<B>myPara</B>") alert("³ªÀÇ À̸§Àº " + doc.<B>tagName</B> + " element ÀÔ´Ï´Ù. ") } function <B>getName</B>() { var doc=document.<B>getElementsByName</B>("<B>myName</B>") alert("¸ðµÎ " + doc.<B>length</B> + " °³ ÀÔ´Ï´Ù. ") } //--> </script> </head> <body> <button id="<B>myPara</B>" onclick="<B>getElement</B>()"> Ŭ¸¯ÇÏ¸é ³ªÀÇ Element À̸§ÀÌ ³ª¿É´Ï´Ù. </button><br /> <input name="<B>myName</B>" /><br /> <input name="<B>myName</B>" /><br /> <input name="<B>myName</B>" /><br /> <button onclick="<B>getName</B>()">Ŭ¸¯Çϸé ElementÀÇ °¹¼ö°¡ ³ª¿É´Ï´Ù.</button> </body> </html> </PRE><!-- ÀÔ·Â pre ³¡--><A href="javascript:copy2Clipboard(id_name);open_window('../../include/code_executor.asp');"><IMG alt="ÄÚµå ½ÇÇà Çϱâ" src="http://www.cadvance.org/doc/images/icon/exec_button.gif" border=0></A><BR><BR><BR> <HR class=blackHr>
÷ºÎÆÄÀÏ
°ßÀû°è»êÇϱâ
ÀÛ¾÷ÀÇ·Ú
°ßÀû¹®ÀÇ
°øÁö»çÇ×