À¥ÆäÀÌÁö¿¡ À¥Ç¥ÁØ »ç¿ëÇϱâ

À¥°³¹ßÀÚµé »çÀÌ¿¡¼­ DHTMLÀ» Ãß°¡Çϰųª À¥ÆäÀÌÁöÀÇ Å©·Î½ººê¶ó¿ìÀú Áö¿øÀ̶ó°í ¿©°ÜÁø ¼ö¸¹Àº ¿ä¼Ò¿Í °üÇàµéÀÌ W3C HTML 4.0°ú ¹®¼­°´Ã¼¸ðµ¨ »ç¾ç¿¡¼­ Á¦¿ÜµÇ¾ú½À´Ï´Ù. ¿¹¸¦ µé¾î, <LAYER> °ú document.layers[]°ú °°Àº °´Ã¼´Â ½ÇÁ¦·Î ¾î¶² À¥Ç¥ÁØ¿¡ ÇØ´çÇÏÁöµµ ¾Ê½À´Ï´Ù. ³×½ºÄÉÀ̽º °ÔÄÚTM-±â¹Ý ¸ðÁú¶ó¿Í ³×½ºÄÉÀÌÇÁ 6/7°ú °°Àº W3C Ç¥ÁØÀ» µû¸£´Â »õ·Î¿î ºê¶ó¿ìÀú´Â ÀÌµé ¼Ó¼º°ú ºñȣȯ ¿ä¼Ò¸¦ Áö¿øÇÏÁö ¾Ê½À´Ï´Ù.

A number of elements and practices considered "standard" among web developers for adding DHTML and/or cross-browser support to their web pages were excluded from the W3C HTML 4.0 and Document Object Model specifications. Tags like <LAYER> and objects like document.layers[], for example, are actually not a part of any web standard. Newer browsers that comply with the W3C standards, such as the Netscape GeckoTM-based Mozilla and Netscape 6/7, do not support these proprietary and non-compliant elements.

¿©±â¿¡ ÀÖ´Â ³»¿ëÀº ¿©·¯ºÐÀÇ À¥ÆäÀÌÁö¸¦ W3 À¥Ç¥ÁØ¿¡ ¸Âµµ·Ï ¾÷±×·¹ÀÌµå ¹æ¹ýÀ» °³°ýÇÑ ³»¿ëÀÔ´Ï´Ù. Ç¥Áذú ´Ù¸¥ ÀÏ¹Ý °üÇàÀ» ¹ÝÀüÇÏ¿© Ç¥½ÃÇÏ¿´À¸¸ç ´ëü¹æ¹ýÀ» Á¦°øÇϸç, ±×¸®°í ¸¶Áö¸· ´Ü¿øÀÇ º¯°æ³»¿ë ¿ä¾àÀº ÀÌ ±Û¿¡¼­ ¼³¸íÇÑ ¸ðµç º¯°æ»çÇ×À» Á¤¸®ÇÏ¿´½À´Ï´Ù.

This article provides an overview of the process for upgrading the content of your web pages to conform to the W3 Web standards. The various sections highlight areas in which common practices are at odds with the standards and suggest replacements, and the final section, Summary of Changes, outlines all the changes described in this article.

À¥°³¹ß¿¡¼­ Ç¥ÁØÀ» »ç¿ëÇÑ´Ù´Â °ÍÀº Á¤¸»·Î  ºê¶ó¿ìÀú³ª Ç÷§Æû¿¡ »ó°ü¾øÀÌ, ÀϰüµÈ ±¸¼º°ú dzºÎÇÑ ¹®¼­°´Ã¼¸ðµ¨·Î, °¡µ¶¼ºÀÖÀ¸¸é È®ÀåÇÒ ¼ö ÀÖµµ·Ï, ±×¸®°í ´õ³ª¾Æ°¡ Ç¥ÁØÈ­ÀÛ¾÷ ±× ÀÚüÀÇ ´ëÀÇ¿¡ ¸Â°Ô ¿©·¯ºÐÀÇ »çÀÌÆ®¸¦ ¸¸µç´Ù´Â °ÍÀÔ´Ï´Ù.

Using standards in your web development makes your pages genuinely cross-browser and cross-platform, makes them a part of a coherent and robust document object model, makes them readable and extensible by others, and also furthers the cause of the standardization process itself.

¹® ¼­³»¿ë:

Layers¿Í LAYER ¿ä¼Ò

Layers and LAYER Elements

ÀÌ ´Ü¿øÀº <LAYER> ¿ä¼Ò, ÇØ´ç ¿ä¼Ò¿¡ ´ëÇÑ DOM ÀÌ¿ë, ±×¸®°í Ç¥ÁØÀ» ÁؼöÇÏ´Â HTML·Î ´ëüÇÏ´Â ¸î°¡Áö ¹æ¹ýÀ» ¼³¸íÇÕ´Ï´Ù.

This section describes the <LAYER> element, DOM access to that element, and some strategies for replacing it with standards-compliant HTML.

Layer ¿ä¼ÒÀÇ ¸ð½À

Layer´Â ¾î¶² W3C À¥Ç¥ÁØ¿¡µµ ÇØ´çÇÏÁö ¾Ê±â ¶§¹®¿¡,³×½ºÄÉÀÌÇÁ 6/7 ±×¸®°í Mozilla´Â layer¸¦ Áö¿øÇÏÁö ¾Ê½À´Ï´Ù. layer¸¦ Áö¿øÇÏÁö ¾Ê´Â ´Ù¸¥ ºê¶ó¿ìÀúó·³, °ÔÄÚ¿£ÁøÀº LAYER, ILAYER, ±×¸®°í NOLAYER űװ¡ ¾ø´Â °ÍÀ¸·Î HTMLÀ» ó¸®ÇÕ´Ï´Ù.

Because layers are not part of any W3C web standard, Netscape 6/7 and Mozilla do not support layers. Like any other browser that doesn't support layers, Gecko renders the HTML as if the LAYER, ILAYER, and NOLAYER tags were not there.

document.layers[] ±×¸®°í ³×ºñ°ÔÀÌÅÍ 4 Layer DOMÀÇ ´Ù¸¥ ±â´ÉÀº ¸¶Âù°¡Áö·Î Áö¿øµÇÁö ¾ÊÀ¸¸ç, ¾Æ·¡¿¡ ¼³¸íµÇ¾î ÀÖ½À´Ï´Ù.

document.layers[] and other features of the Navigator 4 Layer DOM are similarly not supported, as discussed below.

¡¡

Layer ¿ä¼Ò ¾÷µ¥ÀÌÆ®Çϱâ

updating Layer Elements

LAYER, ILAYER, and NOLAYER ¿ä¼Ò¸¦ »ç¿ëÇÏ´Â À¥ ÆäÀÌÁö¸¦ ¾÷µ¥ÀÌÆ®Çϸé,Ç¥ÁØÀ» ±â¹ÝÀ¸·ÎÇÏ´Â ºê¶ó¿ìÀú°¡ ´ëºÎºÐ ºñȣȯ ¿ä¼Ò ¸ðµÎ¸¦ ¹«½ÃÇÏ´Â ÀÌÁ¡À» ¾òÀ» ¼ö ÀÖ½À´Ï´Ù. FRAME°ú IFRAMEÀº LAYER¿Í ILAYER¿¡ ´ëÇÑ ÈǸ¢ÇÑ Ç¥ÁØÀ» ±â¹ÝÀ¸·ÎÇÏ´Â ´ëü ¿ä¼ÒÀÔ´Ï´Ù.  LAYER SRC=newcontent.html ¹æ½ÄÀ¸·Î ¿©·¯ºÐ ¹®¼­¿¡ °¡Á®¿À·Á´Â ³»¿ëÀÌ ÀÖ´Ù¸é, IFRAME SRC=newcontent.htmlÀ»
´ë½Å »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.

To update web pages that use the LAYER, ILAYER, and NOLAYER elements, you can take advantage of the fact that standards-based browsers typically ignore non-compliant elements altogether. In general, the FRAME and IFRAME elements are good, standards-based replacements for LAYER and ILAYER, respectively. If you have content that you want to import into your document with the LAYER SRC=newcontent.html model, you can use IFRAME SRC=newcontent.html instead.

ÇöÀçÀÇ Ç¥Áذú ³×½ºÄÉÀÌÇÁ 4¿¡ ȣȯ°¡´ÉÇÑ À¥ÆäÀÌÁö¸¦ ¸¸µé ¼ö ÀÖ´Â ÁÁÀº ¹æ¹ýÀº LAYER ¿ä¼Ò¿¡ IFRAME ¿ä¼Ò¸¦ ¸ðµÎ »ç¿ëÇÏ´Â °ÍÀÔ´Ï´Ù. ³×½ºÄÉÀÌÇÁ 4´Â IFRAME ¿ä¼Ò¸¦ Áö¿øÇÏÁö ¾Ê±â ¶§¹®¿¡, IFRAMEÀº Ç¥ÁØÀÇ ÀϺÎÀÔ´Ï´Ù. ´ÙÀ½ÀÇ ¿¹Á¦´Â ³×½ºÄÉÀÌÇÁ 4¿Í IFRAMEÀ» Ç¥ÁØÀ¸·Î ÇÏ´Â ºê¶ó¿ìÀú¿¡¼­ µ¿ÀÏÇÑ °á°ú¸¦ º¸¿©ÁÝ´Ï´Ù.

A good strategy for making your web page compatible with both the current standard and Netscape 4 is to use both an IFRAME element in a LAYER
element. Since Netscape 4 does not support the IFRAME element, which is part of the standard, the following examples will yield equivalent results on Netscape 4 and on browsers that conform to the standard for IFRAME's:

°°Àº À̸§ÀÇ ILAYER·Î IFRAMEÀ» °¨½Î¼­ ¿ÜºÎÆÄÀÏÀ» Æ÷ÇԽʴϴÙ.

Nav4: LAYER 󸮵ǰí, IFRAMEÀº ¹«½ÃµË´Ï´Ù.
Nav6¿Í IE4/5: IFRAMEÀº 󸮵Ǹç, LAYER´Â ¹«½ÃµË´Ï´Ù.

<LAYER NAME="foo" SRC=foo.html>
    <IFRAME ID="foo" SRC=foo.html>
    </IFRAME>
</LAYER>
°°Àº À̸§ÀÇ IFAMEÀ¸·Î LAYER¸¦ °¨½Î¼­ ¿ÜºÎ ÆÄÀÏÀ» Æ÷ÇÔ½Ãŵ´Ï´Ù.
Nav4: LAYER´Â 󸮵ǰí IFRAMEÀº ¹«½ÃµË´Ï´Ù.
Nav6¿Í IE4/5: IFRAMEÀº 󸮵ǰí LAYER´Â ¹«½ÃµË´Ï´Ù.

<IFRAME ID="foo" SRC=foo.html> 
    <LAYER NAME="foo" SRC=foo.html>
    </LAYER>

</IFRAME>

¿·¿¡´Ù °° Àº À̸§ÀÇ LAYER¿Í IFRAME¸¦ »ç¿ëÇØ¼­ ¿ÜºÎÆÄÀÏÀ» Æ÷ÇÔ½Ãŵ´Ï´Ù.:
Nav4: LAYER´Â 󸮵ǰí IFRAMEÀº ¹«½ÃµË´Ï´Ù.
Nav6¿Í IE4/5: IFRAMEÀº 󸮵ǰí LAYER´Â ¹«½ÃµË´Ï´Ù.

<LAYER NAME="foo" SRC=foo.html>
</LAYER
<IFRAME ID="foo" SRC=foo.html>
</IFRAME>

º¯È¯Ã³¸®(transcluded)µÈ ¿ÜºÎÆÄÀÏÀ» ÅëÇØ¼­ Nav4¸¦ À§ÇÑ ³»¿ë°ú IE4¿Í NAV6¸¦ À§ÇÑ ³»¿ëÀ» ¼±ÅÃÀûÀ¸·Î Ç¥½ÃÇÕ´Ï´Ù.(NOLAYER¸¦ µÑ·¯½Î¼­ Ç¥½ÃÇϱ⠶§¹®¿¡ NAV4´Â <NOLAYER>¿Í </NOLAYER>ÀÇ ¸ðµç ³»¿ëÀ» ¹«½ÃÇÕ´Ï´Ù.)


Selectively displaying some content for Nav4 (via transcluded external file) and other content for IE4+ and Nav6 (enclosing in NOLAYER so Nav4 ignores everything between <NOLAYER> and </NOLAYER>):

Nav4: LAYER´Â 󸮵ǰí NOLAYER¿Í ³»¿ëÀº ¹«½ÃµË´Ï´Ù.
Nav6¿Í IE4/5: LAYER¿Í NOLAYER´Â ¹«½ÃµÇ°í DIV´Â 󸮵˴ϴÙ.

<LAYER NAME="nav4content" SRC=foo.html>
</LAYER>
<NOLAYER>
  <DIV ID="nav6content">
     <!-- ... bunch of elements ... -->
  </DIV>
</NOLAYER>

Div ¿ä¼Ò

Div Elements

DIV ¿ä¼Ò´Â W3C HTML 4.0 Ç¥ÁØÀÌ¶ó¼­ ¸ðÁú¶ó¿Í ´Ù¸¥ Ç¥Áرâ¹Ý ºê¶ó¿ìÀú¿¡¼­ Áö¿øÇÕ´Ï´Ù. ¿ÜºÎ¿¡ ÀÖ´Â ÆäÀÌÁö¸¦ °¡Á®¿À±â ¿ìÇØ DIV¿¡¼­ °øÅëÀûÀ¸·Î »ç¿ëµÇ´Â SRC ¼Ó¼ºÀº °ø½ÄÇ¥ÁØÀÌ ¾Æ´Õ´Ï´Ù.

The DIV element is a part of the W3C HTML 4.0 standard, and as such it is supported by Mozilla and other standards-based browsers. The SRC attribute commonly used on the DIV to import content external to the page, however, is not a part of the official standard.

ÅØ½ºÆ® ºí·Ï, ¶Ç´Â ºÐÇÒÇϱâ À§ÇØ DIV¸¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. DIV ¿ä¼Ò´Â ³×ºñ°ÔÀÌÅÍ 4 LAYER¿¡ ´ëÇÑ ÀϹÝÀûÀÎ ´ëü¿ä¼Ò·Î »ç¿ëÇÒ ¼ö µµ ÀÖ½À´Ï´Ù. ±×·¯³ª º¯È¯Ã³¸®, Áï ´Ù¸¥ ¿øÃµ¿¡¼­ ³»¿ë¹°À» °¡Á®¿À·Á¸é, ´Ù¸¥ ¼ö´ÜÀ» »ç¿ëÇØ¾ß ÇÕ´Ï´Ù. À¥ÆäÀÌÁö¿¡ ³»¿ë¹°À» °¡Á®¿À´Â ÃÖ»óÀÇ ¹æ¹ýÀº SRC¸¦ »ç¿ëÇÏ¿© IFRAMEÀ» »ç¿ëÇÏ´Â µ¥, ´ÙÀ½ÀÇ ¿¹Á¦ÀÔ´Ï´Ù. µÎ°³ÀÇ DIV ¿ä¼Ò »çÀÌ¿¡ mylist.htmlÀ̶ó´Â ÆäÀÌÁö ³»¿ë¹°À» ÇöÀç ÆäÀÌÁö¿¡ °¡Á®¿À´Â °ÍÀÔ´Ï´Ù.

You can use DIV to create a block of text, or division. The DIV element can also be used as a general replacement for the Navigator 4 LAYER. But to transclude, or import, content from another source, you must use other means. The best way to import content into an element in your web page is to use an IFRAME with a SRC, as in the following example, where the contents of the page mylist.html are imported into the current page between the two DIV elements:

<DIV>
 <UL>
  <LI>Red</li>
  <LI>Blue</li>
  <LI>Yellow</li>
 </UL>
</DIV>
<IFRAME SRC="mylist.html"></IFRAME>
<DIV>
 <UL>
  <LI>Red</li>
  <LI>Blue</li>
  <LI>Yellow</li>
 </UL>
</DIV>

±ÇÀåÇÏÁö ¾Ê´Â ¿ä¼Ò

Deprecated elements

HTML 4¿¡¼­ ±ÇÀåÇÏÁö ¾Ê´Â ¿ä¼ÒµéÀÌ ±¤¹üÀ§ÇÏ°Ô »ç¿ëµÇ°í ÀÖÁö¸¸, ´Ù¸¥ ±â¼ú·Î ´ëüµÇ¾ú½À´Ï´Ù. ±ÇÀåÇÏÁö ¾Ê´Â ¿ä¼Ò¿¡ ´ëÇÑ Áö¿øÀº °¡±î¿î ¹Ì·¡¿¡ ±¤¹üÀ§ÇÏ°Ô ÀÌ¿ëÇÒ ¼ö ÀÖÀ» °Í°°½À´Ï´Ù.

Elements deprecated in HTML 4 are typically in wide use, but have been supplanted by other techniques. Support for the deprecated elements is likely to be widely available for the foreseeable future.

¿©·¯ ±ÇÀåÇÏÁö¾Ê´Â ÅÂ±×¿Í Á¦¿ÜµÈ ű×ÀÇ ±â´ÉÀº W3C ij½ºÄÉÀ̵ù ½ºÅ¸ÀÏ ½ÃÆ® ±Ç°í»çÇ×À» »ç¿ëÀ¸·Î ´ëüµÇ°í ÀÖ½À´Ï´Ù. ½ºÅ¸ÀÏ½ÃÆ®´Â °­·ÂÇÑ ±¸Çö°ú ±¸¼º´É·ÂÀ» Á¦°øÇÕ´Ï´Ù. CSS Àüü¸¦ ³íÀÇÇÏ´Â °ÍÀº ÀÌ ¹®¼­ÀÇ ¹üÀ§¸¦ ¹þ¾î³³´Ï´Ù.

The function of several of the deprecated tags (and of some excluded tags, as well) has been assumed by the W3C Cascading Style Sheets recommendation. Style sheets provide powerful presentation and organization capabilities. A full discussion of CSS is beyond the scope of this document.

CSS Àüü¸¦ Áö¿øÀº ¸¹Àº Ãʱ⠳׺ñ°ÔÀÌÅÍ ºê¶ó¿ìÀú¸¦ Æ÷ÇÔÇÏ¿© ºÎÁ·ÇÑ Á¡ÀÌÁö¸¸, ¿©±â¼­ ¼³¸íÇϰí ÀÖ´Â ´Ü¼øÇÑ ·¹º§¿¡ ´ëÇÑ Áö¿øÀº Nav4¿Í IE 4 ÀÌÈÄ ¹öÀüºÎÅÍ, ±×¸®°í ½ÇÁ¦ÀûÀ¸·Î ¸ðµç Çö´ë ºê¶ó¿ìÀú¿¡¼­ ¾ÆÁÖ Àß Ã³¸®µË´Ï´Ù.

While full CSS support is lacking in many early browsers, including early Navigator versions, support for the simple level illustrated here is fairly well implemented from Nav4 and IE4 onwards, and in virtually all modern browsers.

APPLET

APPLET ¿ä¼Ò´Â HTML 4¿¡¼­ ±ÇÇÏÁö ¾Ê´Â °ÍÀ¸·Î OBJECT¸¦ Áö¿øÇÕ´Ï´Ù. µÎ ű׻çÀÌÀÇ º¯È¯Àº º¸´Â ±×´ë·ÎÀÔ´Ï´Ù :

The APPLET element is deprecated in HTML 4, in favor of OBJECT. The translation between the two tags is straightforward, e.g.:

<APPLET code="appletname.class"
    codebase="..." archive="..." width="..." height="...">
  <PARAM name="..." value="..."> [...]
</APPLET>
Äڵ带 ¾Æ·¡¿Í °°Àº ½ÄÀ¸·Î ÇÕ´Ï´Ù.
<OBJECT classid="java:appletname.class" type="application/java"
    codebase="..." archive="..." width="..." height="...">
  <PARAM name="..." value="..." /> [...]
</OBJECT>

ÁÖÀÇ»çÇ× : ÀÓº£µù ¾ÖÇø´¿¡ ´ëÇÑ ½ã ¸¶ÀÌÅ©·Î½Ã½ºÅÛÁî°¡ °ø½ÄÈ­ÇÑ HTMLÀº ÀÚ¹Ù Ç÷¯±×ÀÎÀ» ±â¹ÝÀ¸·ÎÇϸç À©µµ¿ìÁî ÀÎÅͳÝÀͽºÇ÷η¯ ¶Ç´Â À©µµ¿ìÁî ³×ºñ°ÔÀÌÅÍ ¶Ç´Â ¸®´ª½º ÀÌ¿ÜÀÇ ´Ù¸¥ ½Ã½ºÅÛ¿¡¼­´Â ȣȯµÇÁö¾Ê´Â °Í°°½À´Ï´Ù. °ÔÄÚ ¿£ÁøÀº ½ãÀÇ EMBED ű׸¦ Áö¿øÀ» °è¼ÓÇϰí ÀÖÁö¸¸, À§¿¡¼­ ¾ð±ÞÇÑ OBJECT ű׿ʹ ÀüÇô ´Ù¸¥ ActiveX¸¦ »ç¿ëÇÏ´Â OBJECT ű׸¦ Áö¿øÇÏÁö ¾Ê½À´Ï´Ù.

¡¡

Note: the HTML promulgated by Sun Microsystems for embedding applets is based on the Java Plug-in and is not likely to be compatible with systems other than Internet Explorer for Windows or Navigator for Windows or Linux. While Gecko maintains support for Sun's EMBED tag, it does not support the ActiveX-invoking OBJECT tag (very different from the OBJECT tag above), which is used to run the Java Plug-in.

FONT

ºñ±ÇÀå FONT ¿ä¼Ò´Â ±Û²Ã, »ö»ó, ƯÁ¤ ¹®ÀåÀÇ Å©±â¸¦ ÁöÁ¤ÇÏ´Â µ¥ ±¤¹üÀ§ÇÏ°Ô »ç¿ëµË´Ï´Ù. ÀÌ ±â´ÉÀº HTML¿Í  CSS¿¡¼­ »ç¶óÁ³½À´Ï´Ù. FONT ¿ä¼Ò´Â µ¿ÀÏÇÑ ½ºÅ¸ÀÏ Á¤º¸¸¦ Æ÷ÇÔÇÏ´Â SPAN À¸·Î ¹Ù·Î ´ëóÇÒ ¼ö ÀÖ½À´Ï´Ù.

The deprecated FONT element is widely used to specify typeface, color and size of the enclosed text. This functionality has been offloaded from HTML to CSS. The FONT element can be directly replaced with a SPAN element that includes the same style information:

<P><FONT color="blue" face="Helvetica">
A really <FONT size="+1">big</FONT> shoe.
</FONT>
Äڵ带 ¾Æ·¡¿Í °°Àº ½ÄÀ¸·Î ÇÕ´Ï´Ù.
<P><SPAN style="color:blue; font:Helvetica">
A really <SPAN style="font:larger">big</SPAN> shoe.
</SPAN><P>
¶Ç´Â ´õ ÀϰüµÈ ÇüÅ´ °ÍÀ¸·Î´Â ´ÙÀ½°ú °°ÀÌ ÇÕ´Ï´Ù.
<P style="color:blue; font:Helvetica">
A really <SPAN style="font:larger">big</SPAN> shoe.
<P>

ÀÌ·¸°Ô ÇÏ´Â °ÍÀÌ ±Û²Ã º¯°æ¿¡ ÀûÇÕÇÑ »ç¿ë¹ýÀÔ´Ï´Ù. ±×·¯³ª À̰ÍÀº ½ºÅ¸ÀÏÀ» »ç¿ëÇÏ´Â °Ô ÃÖ°í¶ó´Â °ÍÀº ¾Æ´Õ´Ï´Ù. CSSÀÇ ÈûÀº ¾î¶² ¹®¼­ ¸ðµÎ¿¡ Àû¿ëÇÒ ¼ö ÀÖµµ·Ï ÅØ½ºÆ®¸¦ ¹­°í ³í¸®Àû ±×·ìÀ¸·Î ¸¸µé¾î ´Ù¸¥ ½ºÅ¸ÀÏÀ» Àû¿ëÇÏ´Â µ¥ ÀÖ´Â µ¥, ÀÌ °úÁ¤¿¡¼­ ¸ðµç ¿ä¼Ò¿¡ ƯÁ¤ ½ºÅ¸ÀϸµÀ» ¹Ýº¹ÇÒ Çʿ䰡 ¾ø´Ù´Â °ÍÀÔ´Ï´Ù.

This is appropriate usage for a local change to the font. However, this is not the best use of styles; the strength of CSS lies in the ability to gather text and other styling into logical groupings that can be applied across a document, without repeating the specific styling on every element that requires it.

´Ù¸¥ ºñ±Ç°í ¿ä¼Ò

ºñ±Ç°í ¿ä¼Ò W3C ´ëü¹æ¹ý
CENTER CSS1: text-align:center
S
STRIKE
CSS1: text-decoration:line-through
U CSS1: text-decoration:underline
DIR
MENU
HTML 4.0: <UL>

´Ù¸¥ Á¦¿ÜµÈ ¿ä¼Ò

Other Excluded Elements

¾Ö´Ï¸ÞÀ̼ÇÀ» À§ÇÑ ¼ö¸¹Àº µ¶Á¡Àû ¿ä¼Ò¿Í ¾î¶² À¥Ç¥ÁØ¿¡µµ ¼ÓÇÏÁö ¾Ê´Â ´Ù¸¥ Æí¹ýµéÀÌ Á¸ÀçÇÕ´Ï´Ù. ÀÌ ´Ü¿øÀº ÀÌµé ¿ä¼Ò¸¦ Á¦½ÃÇϰí W3C HTML 4.0À¸·Î µ¿ÀÏÇÑ È¿°ú¸¦ ¾òÀ» ¼öÀÖ´Â ¹æ½ÄÀ» Á¦¾ÈÇÕ´Ï´Ù.

There are a number of proprietary elements used for animation and other tricks that are not a part of any web standard. This section highlights those elements and suggests practices for achieving the same effect with W3C HTML 4.0:

Á¦¿ÜµÈ ¿ä¼Ò W3C ´ëü¹æ¹ý
BLINK
Nav2+
CSS1 text-decoration:blink
ÁÖÀÇ»çÇ× : CSS1 »ç¾çÀº blink Ű¿öµå¸¦ ÀνÄÇϱâ À§ÇØ »ç¿ëÀÚ ºê¶ó¿ìÀú¸¦ ÇÊ¿ä·Î ÇÏ´Â µ¥, ±ôºýÀÓ È¿°ú¸¦ Áö¿øÇÏÁö ¾Ê´Â´Ù¸é, CSS1-ÁؼöÇÏ´Â ºê¶ó¿ìÀú´Â ÇØ´ç ¹®±¸¸¦ È­¸é¿¡ ±ôºýÀÌ°Ô ÇÒ ¼ö Àְųª ±×·¸Áö ¸øÇÒ ¼ö ÀÖ½À´Ï´Ù. °¡Àå ÁÁÀº ¹æ¹ýÀº ³»¿ë¿¡ blink¸¦ ÀüÇô ¸¸µéÁö ¾Ê´Â °ÍÀÔ´Ï´Ù.

user agents are required by the CSS1 specification to recognize the blink keyword, but not to support the blink effect, so CSS1-compliant browsers may or may not make the text blink on the screen. The best approach is not to make content blink at all.
MARQUEE
IE2+
HTMl .40ÀÇ DIV ¶Ç´Â SPAN´Â DOM level 1À» »ç¿ëÇØ¼­ ÀÚ¹Ù½ºÅ©¸³Æ®·Î ÄÁÅÙÃ÷ ¹®ÀÚ¿­À» ȸÀü½Ãŵ´Ï´Ù. ÁÖÀÇ»çÇ× : DOM Áö¿øÀº ºê¶ó¿ìÀú¸¶´Ù ¿©·¯°¡ÁöÀÔ´Ï´Ù. ±ôºýÀÓ(blinking) ¹®±¸Ã³·³, ÀÌ·± Á¾·ù´Â ±ÇÀåÇÏÁö ¾Ê½À´Ï´Ù.

HTML 4.0 DIV or SPAN, with content string rotated over time by JavaScript via the DOM level 1.
Note: DOM support varies among browsers. As with blinking text, this sort of effect is discouraged.
BGSOUND
IE2+
HTML 4.0ÀÇ OBJECT ¿¹¸¦ µé¸é ´ÙÀ½°ú °°´Ù:
<OBJECT data="audiofile.wav" type="audio/wav" ...></OBJECT>
ÆäÀÌÁö³»¿¡¼­ º¼ ¼ö ¾ø´Â »ç¿îµå OBJECT¸¦ 󸮹æ¹ýÀº ¾Æ·¡ÀÇ EMBED Ç׸ñÀÇ ¸µÅ©¸¦ Âü°íÇϱ⠹ٶø´Ï´Ù. ÁÖÀÇ»çÇ×: À§ÀÇ ÅØ½ºÆ® È¿°úó·³, ÆäÀÌÁö¿Í ÇÔ²² ³ª¿À´Â À½¾Ç ¶Ç´Â »ç¿îµå´Â °áÄÚ ³ôÀÌ Æò°¡ÇÒ¸¸ÇÏÁö ¾Ê½À´Ï´Ù.

HTML 4.0 OBJECT, e.g.:
<OBJECT data="audiofile.wav" type="audio/wav" ...></OBJECT>
See link in EMBED item below for information on rendering a sound OBJECT invisible within the page.
Note: like the text effects above, music or sound accompanying a page is seldom appreciated.
EMBED
Nav2+,IE3+
HTML 4.0ÀÇ OBJECT »ç¿ë. EMBED ű׸¦ OBJECT ű׷ÎÀÇ º¯È¯ ¹æ¹ýÀº ÀÌ DevEdge ±â»ç¸¦ Âü°íÇϼ¼¿ä. ÁÖÀÇ»çÇ× : EMBED ű״ W3C ±Ç°í»çÇ׿¡ ¼ÓÇÏÁö ¾ÊÁö¸¸, ¿©ÀüÈ÷ °ÔÄÚ¿£Áø°ú ´Ù¸¥ Çö´ëÀûÀÎ ºê¶ó¿ìÀú°¡ Áö¿øÇÕ´Ï´Ù.  Áö¿ø¼öÁصµ °¢°¢Àε¥ ÀÎÅͳÝÀͽºÇ÷η¯ ±â¼úÁö¿øÀº ´ëºÎºÐÀÇ ³×½ºÄÉÀÌÇÁ Ç÷¯±×Àΰú ȣȯµÇÁö¾Ê½À´Ï´Ù. OBJECT¿¡ ´ëÇÑ ±â¼úÁö¿øÀº º¸ÆíÀûÀÌÁöµµ, ÀÌÀü ºê¶ó¿ìÀú¿¡´ëÇØ¼­´Â ´õ¿í ±×·¸½À´Ï´Ù.

HTML 4.0 OBJECT. See this DevEdge article for information on translating EMBED tags into OBJECT tags.
Note: EMBED has never been part of a W3C HTML recommendation, yet it is still supported by Gecko and other modern browsers. Quality of support varies; Internet Explorer's support is incompatible with most Netscape plugins. Support for OBJECT is not universal, either, particularly for older browsers.

DOM »ç¿ëÇϱâ

Using the DOM

ÀϺΠºê¶ó¿ìÀú¿¡¼­ document °´Ã¼´Â ¿ä¼Ò ¹è¿­(array)°ú ¿ä¼Ò Çü½ÄÀ» ÀÌ¿ëÇϱâ À§ÇÑ ¼Ó¼ºÀ» °¡Áö°í ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î document.tags´Â °´Ã¼ ¸ðµ¨³»¿¡¼­ ƯÁ¤ ¿ä¼Ò¸¦ »ç¿ëÇϱâ À§ÇØ ³×½ºÄÉÀÌÇÁ 4°¡ »ç¿ëÇÏ´Â µ¥, ÀÎÅͳÝÀͽºÇ÷η¯ÀÇ ¹®¼­ °´Ã¼ ¸ðµ¨¿¡¼­µµ document.all[]ÀÌ »ç¿ëµÇ°í ÀÖ½À´Ï´Ù. ÀÌµé ¹è¿­(array)ÀÇ ¸¹Àº °ÍÀº ¹®¼­ °´Ã¼ ¸ðµ¨ÀÇ »ç¾çÀÇ ÀϺΰ¡ ¾Æ´Ï¿´À¸¸ç ¸ðÁú¶ó¿Í ³×½ºÄÉÀÌÇÁ 6/7°ú °°Àº Ç¥ÁØÀ» µû¸£´Â ºê¶ó¿ìÀú¿¡¼­ ÀÚ¹Ù½ºÅ©¸³Æ® ¿À·ù¸¦ ¹ß»ý½ÃŰ°Ô µÈ´Ù.

The document objects for some browsers have properties for accessing arrays of elements and types of elements. document.tags, for example, is used by Navigator 4 to access particular elements within the object model, just as document.all[] is in the Internet Explorer document object model. Many of these arrays were not made a part of the specification for the Document Object Model, and will cause JavaScript errors in standards-compliant browsers like Mozilla and Netscape 6/7.

W3C ¹®¼­ °´Ã¼ ¸ðµ¨Àº HTML ÆäÀÌÁö¿¡ ÀÖ´Â °ÅÀÇ ¸ðµç ¿ä¼Ò¸¦ ÀÛ¼º°¡´ÉÇÑ °´Ã¼·Î½á ³ëÃâ½Ãŵ´Ï´Ù. ÀϹÝÀûÀ¸·Î DOMÀÇ ¸Þ¼­µå(methods)¿Í Àüü °´Ã¼ ¸ðµ¨Àº DHTML ÇÁ·Î±×·¡¹Ö¿¡ »ç¿ëµÇ´Â µ¶Á¡ °´Ã¼ ¸ðµ¨º¸´Ù ÈξÀ ´õ ¼¼¹ÐÇÕ´Ï´Ù. 

The W3C Document Object Model exposes almost all of the elements in an HTML page as scriptable objects. In general the methods and overall object model of the DOM are much more sophisticated than the proprietary object models used in DHTML programming.

netscape.comÀÇ ÀÌ ±ÛÀº ¾Æ·¡ ¿ä¾àµÈ ÇØ´ç °³³ä¿¡ ´ëÇÑ »ó¼¼ÇÑ ¼Ò°³¸¦ Á¦°øÇÕ´Ï´Ù. ÇØ´ç ÆäÀÌÁö¿¡¼­ Á¦°øµÇ´Â ½ºÅ©¸³Æ®´Â W3C DOMÀ» À§ÇÑ °ÍÀ̸ç, µû¶ó¼­ ȣȯºÒ°¡´ÉÇÑ DOM ¸ðµ¨ÀÇ ºê¶ó¿ìÀú¿¡¼­´Â ¹®Á¦¸¦ ¹ß»ý½Ãŵ´Ï´Ù.ÀÌ·± Â÷À̸¦ ´ëóÇÏ´Â Àü·«À» º¸·Á¸é ¾Æ·¡ ºê¶ó¿ìÀú/Ç÷§Æû µ¶¸³ ÆäÀÌÁö °³¹ßÇϱ⸦ º¸¼¼¿ä.

This article at netscape.com gives a detailed introduction to the concepts summarized below. Note that the scripts provided at that page are designed for the W3C DOM, and will cause problems running on browsers with noncompliant DOM models; see Developing Cross Browser/Cross Platform Pages, below, for strategies on coping with these differences.

Áö¿øµÇÁö¾Ê´Â DOM-°ü·Ã ¼Ó¼º

Unsupported DOM-related Properties

´ÙÀ½ÀÇ document °´Ã¼ ¼Ó¼º(´ëºÎºÐÀº ³×½ºÄÉÀÌÇÁ 4¿¡¼­ ³ª¿Â °ÍÀÔ´Ï´Ù)Àº W3C °´Ã¼ ¸ðµ¨¿¡¼­ Áö¿øµÇÁö ¾Ê½À´Ï´Ù:

The following document object properties (most originally from Netscape 4) are not supported in the W3C Document Object Model:

¿ø·¡ ÀÎÅÍ³Ý ÀͽºÇ÷η¯¿¡¼­ ¸¸µé¾îÁø ´ÙÀ½ÀÇ ¿ä¼Ò ¼Ó¼ºÀº ¸¶Âù°¡Áö·Î W3C ¹®¼­ °´Ã¼ ¸ðµ¨¿¡¼­ Áö¿øµÇÁö ¾Ê´Â °ÍÀÔ´Ï´Ù:

The following element properties (originally from Internet Explorer) are likewise not supported in the W3C Document Object Model:

ÀÌµé ¼Ó¼ºÀ» »ç¿ëÇÏ´Â ½ºÅ©¸³Æ®´Â ³×½ºÄÉÀÌÇÁ 6/7 ¶Ç´Â ´Ù¸¥ Ç¥ÁØÀ» µû¸£´Â ºê¶ó¿ìÀú¿¡¼­ ½ÇÇàµÇÁö¾Ê½À´Ï´Ù. ´ë½Å¿¡ ´ÙÀ½ ´Ü¿ø¿¡¼­ ¼³¸íÇÏ´Â DOM »ç¿ë ¹æ½ÄÀ» »ç¿ëÇϼ¼¿ä. ¶ÇÇÑ ½ºÅ¸ÀÏ ±ÔÄ¢À» ÀÌ¿ëÇϱâ À§ÇØ DOMÀ» »ç¿ëÇÑ ¿¹Á¦¶ó¸é ¹®¼­ ½ºÅ¸Àϰú ³»¿ë Á¶ÀÛÇϱ⸦ º¸¼¼¿ä.

Scripts that use these properties will not execute in Netscape 6/7 or other standards-compliant browsers. Instead, use the DOM access methods described in the next section. Also see Manipulating Document Style and Content for examples of using the DOM to access style rules.

DOMÀ¸·Î ¿ä¼Ò »ç¿ëÇϱâ

Accessing Elements with the DOM

HTML ÆäÀÌÁö¿¡¼­ ¿ä¼Ò¸¦ »ç¿ëÇÏ´Â °¡Àå ÈǸ¢ÇÏ´Â ¹æ¹ýÀº ¹®¼­ °´Ã¼ ¸ðµ¨ document.getElementById(id)¸¦ È£ÃâÇÏ´Â °ÍÀÔ´Ï´Ù. ÀÌ·± ¹æ¹ýÀ» »ç¿ëÇØ¼­ À¯ÀÏÇÏ°Ô ÀνĵǴ ¿ä¼Ò¿¡ ´ëÇÑ °´Ã¼ ÂüÁ¶¸¦ ÇÏ°Ô µÇ´Â µ¥, ÀÌ·¸°Ô ÇÑ µÚ¿¡ ÇØ´ç ¿ä¼Ò¸¦ ÀÛ¼ºÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î, ´ÙÀ½ÀÇ ÂªÀº ¿¹Á¦´Â µ¿ÀûÀ¸·Î DIV ¿ä¼ÒÀÇ ÁÂÃø ¿©¹éÀ» "inset"À̶ó´Â ID·Î ¹ÝÀÎÄ¡¸¦ ¼³Á¤ÇÏ´Â °ÍÀ» º¸¿©ÁÖ°í ÀÖ½À´Ï´Ù.

The best practice for getting scriptable access to an element in an HTML page is to call the Document Object Model's document.getElementById(id). This method returns an object reference to the uniquely identified element, which can then be used to script that element. For example, the following short sample dynamically sets the left margin of a DIV element with an ID of "inset" to half an inch:

// HTML³»¿¡¼­´Â ´ÙÀ½°ú °°ÀÌ: <DIV id="inset">Sample Text</DIV>
d = document.getElementById("inset");
d.style.margin-left = ".5in";

¿ä¼Ò ±×·ìÀ» ÀÌ¿ëÇÏ·Á¸é, DOM¿¡¼­´Â getElementsByTagName¸¦ Æ÷ÇÔÇϰí ÀÖ´Â µ¥, ÀÌ·± ½ÄÀ¸·Î ¸ðµç ¿ä¼ÒÀÇ ¸ñ·ÏÀ» ÁÖ¾îÁø ÅÂ±× À̸§À¸·Î ¼ø¼­´ë·Î ¹®¼­¿¡ º¸¿©ÁÝ´Ï´Ù.

For accessing a group of elements, the DOM specification also includes getElementsByTagName, which returns a list of all the elements with the given tag name in the order they appear in the document:

anks = document.getElementsByTagName("a");
first_a = anks[0];
alert(first_a.href);

DOM2 »ç¾çÀº getElementsByTagNameNS¶ó°í ºÎ¸£´Â Ưº°ÇÑ getElementsByTagName ¹öÀüÀ» Æ÷ÇÔÇϱ⵵ ÇÏ´Â µ¥, ÀÌ·± ½ÄÀ¸·Î ÁöÁ¤µÈ ³×ÀÓ½ºÆäÀ̽º³»¿¡ ÀÖ´Â ÅÂ±× ¸ñ·ÏÀ» º¸¿©ÁÝ´Ï´Ù. ÀÌ·± ÀÌ¿ë¹æ½Ä°ú ´õºÒ¾î, DOMÀº »õ·Î¿î ¿ä¼Ò, ¹®¼­´ÜÆí(fragment), ¼Ó¼ºÀ» »ý¼ºÇÏ´Â µ¥, ³»¿ë Æ®¸®¸¦ ³Ñ³ªµå´Â µ¥, ±×¸®°í ¹®¼­ ÀÚü¿Í »óÈ£ÀÛ¿ëÇÒ ¶§ ¹ß»ýÇÏ´Â À̺¥Æ®¸¦ ó¸®ÇÏ´Â ¹æ½ÄÀ» Á¦°øÇÕ´Ï´Ù.

The DOM2 specification also includes a special version of getElementsByTagName called getElementsByTagNameNS, which returns a list of tags within a specified namespace. In addition to these access methods, the DOM provides methods for creating new elements, document fragments, attributes, new content, for traversing the content tree, and for handling events raised as the user interacts with the document itself.

¹®¼­ ½ºÅ¸Àϰú ³»¿ë Á¶ÀÛÇϱâ

Manipulating Document Style and Content

DomÀ» »ç¿ëÇØ¼­ ¹®¼­ÀÇ ½ºÅ¸ÀÏ½ÃÆ® º¯°æÇϱâ

Changing an Document's Style Sheet Using the DOM

´Ù¸¥ ºê¶ó¿ìÀúµéÀº À¥ÆäÀÌÁö¿¡ Á¤ÀÇµÈ ½ºÅ¸ÀÏ ±ÔÄ¢À» ÀÌ¿ëÇÏ¿© Á¶ÀÛÇϱâ À§Çؼ­ ´Ù¸¥ ºê¶ó¿ìÀú¸¦ Á¦°øÇÏ¿©¿Ô½À´Ï´Ù. ÀÎÅÍ³Ý ÀͽºÇ÷η¯ÀÇ document.all.element.style ¼Ó¼º°ú ³×ºñ°ÔÀÌÅÍ 4ÀÇ document.tags, document.classes, and document.contextual()´Â ´ÙÀ½ÀÇ ¿¹Á¦¿¡¼­Ã³·³ DOME Level 2 CSS ÀÎÅÍÆäÀ̽º È£Ãâ·Î ´ëüÇÒ ¼ö ÀÖ½À´Ï´Ù.

Different browsers have provided different ways to access and manipulate the style rules defined for a web page. Internet Explorer's document.all.element.style property and Navigator 4's document.tags, document.classes, and document.contextual() can all be replaced with DOM Level 2 CSS interface calls, as in the following example:

¹®¼­ÀÇ ¸Ó¸´´Ü(HEAD)¿¡¼­ ½ºÅ¸ÀÏ½ÃÆ®¿¡ ´ëÇÑ ÀûÀýÇÑ ±ÔÄ¢À» Ãß°¡Çϱâ À§ÇØ DOM level 2 CSS »ç¿ëÇϰí ÀÖ´Â °ÍÀÔ´Ï´Ù

Using the DOM level 2 CSS interface to add the appropriate rule to a style sheet in the document's HEAD.

<HTML>
<HEAD>
<TITLE>Demo</TITLE>
    <STYLE ID="ietssxyz" TYPE="text/css"></STYLE>
    <SCRIPT LANGUAGE="JavaScript"> <!--
      var targetStyleSheetID = "ietssxyz";
      function addRuleToStyleElement (name, selector, declaration)
      {
        var styleSheetElement = document.getElementById(name);
        var styleSheetLength = styleSheetElement.length;
        styleSheetElement.insertRule (selector + " { " + declaration + " } ", styleSheetLength);
      }
      addRuleToStyleElement (targetStyleSheetID, "h1", "font-size:44pt");
      //-->
    </SCRIPT>
</HEAD>

DOMÀ» »ç¿ëÇØ¼­ ¿ä¼ÒÀÇ ½ºÅ¸ÀÏ º¯°æÇϱâ

Changing an Element's Style Using the DOM

´ÙÀ½ÀÇ Å×À̺íÀº À¥ÆäÀÌÁö¿¡¼­ ¿©·¯ HTML ¿ä¼Ò¿¡ Á¤ÀÇµÈ ½ºÅ¸ÀÏ ±ÔÄ¢À» ÀÌ¿ëÇÏ¿© ¾÷µ¥ÀÌÆ®Çϴ ǥÁØ ¹æ½ÄÀ» ¼³¸íÇÏ´Â ³»¿ëÀÔ´Ï´Ù. W3CÀÇ DOM2 ±Ç°í»çÇ×ÀÎ CSS2 È®Àå ÀÎÅÍÆäÀ̽º¸¦ Âü°íÇϼ¼¿ä.

The following table describes standards-based methods for accessing and updating style rules defined for various HTML elements in a web page. See the W3C DOM2 Recommendation, CSS2 Extended Interface.

DOM level 2´Â element.style °´Ã¼ ÂüÁ¶¸¦ »ç¿ëÇÏ¿© ¿ä¼ÒÀÇ CSS ¼Ó¼º¿¡ »õ·Î¿î °ªÀ» ÇÒ´çÇÒ ¼ö ÀÖ°Ô ÇØÁÝ´Ï´Ù. »ç¿ëÀÚ´Â DOMÀÇ getElementById ¶Ç´Â ¾Õ¼­ DOM ÀÌ¿ë ´Ü¿ø¿¡¼­ ¼³¸íÇÑ ´Ù¸¥ ¹æ½ÄÀ» Áß Çϳª¸¦ »ç¿ëÇÏ¿© ÇØ´ç ½ºÅ¸ÀÏ¿¡ ÇØ´çÇÏ´Â ¿ä¼Ò¸¦ ÀÌ¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.

DOM level 2 provides for the assignment of new values to the CSS properties of an element using the element.style object reference. You can get the element to which that style corresponds by using the DOM's getElementById or one of the other methods described in the DOM access section above.

Nav4: element.visibility = value;
IE4/5: element.style.visibility = value;
DOM level 2: element.style.visibility = value;
Nav4: element.left
IE4/5: element.style.pixelLeft
DOM level 2: parseInt(element.style.left)
Nav4: element.top
IE4/5: element.style.pixelTop
DOM level 2: parseInt(element.style.top)
Nav4: element.moveTo(x,y);
IE4/5: element.style.pixelLeft = x;
  element.style.pixelTop = y;
DOM level 2:
  element.style.left = x + "px";
  element.style.top = y + "px";
¿ä¼ÒÀÇ CSS ¼Ó¼ºÀÇ W3C DOM2 ¹Ý¿µ
W3C DOM2 Reflection of an Element's CSS Properties

ÀÌÁ¡Àº W3CÀÇ ±Ç°í»çÇ×À» µû¸¥´Ù´Â Á¡À» ¿°µÎÇØ µÎ½Ã°í, ¿ä¼ÒÀÇ ½ºÅ¸ÀÏ ¼Ó¼ºÀÌ ¹ÝȯÇÏ´Â °ªÀº ¿ä¼ÒÀÇ ½ºÅ¸ÀÏ ¼Ó¼º¸¸À¸·Î °íÁ¤ ¼³Á¤À» ¹Ý¿µÇÏÁö¸¸, ºÎ¸ð ¿ä¼Ò·ÎºÎÅÍ »ó¼ÓµÈ ½ºÅ¸ÀÏ ¼³Á¤À» Æ÷ÇÔÇÏ´Â ¸ðµç "°è»êµÈ ½ºÅ¸ÀÏ(computed style)"Àº ¾Æ´Õ´Ï´Ù. µû¶ó¼­ DOM2¸¦ »ç¿ëÀ» ÅëÇØ¼­ ÀÌµé ¼Ó¼ºÀ» ÀÚ¹Ù½ºÅ©¸³Æ®·ÎºÎÅÍ ÀÐ°í ¾²·Á°íÇÑ´Ù¸é, ´ÙÀ½ÀÇ Á¢±Ù¹æ¼®Áß Çϳª¸¦ »ç¿ëÇϼ¼¿ä.

  • ¸ðµç ¿ä¼ÒÀÇ °íÁ¤ CSS ¼±¾ð¹®À» ¿ä¼ÒÀÇ ½ºÅ¸ÀÏ ¼Ó¼º¿¡ Àûµµ·Ï ÇÕ´Ï´Ù.
  • ¿ä¼Ò¸¦ À§ÇÑ ºñ°íÁ¤ CSS ¼±¾ð¹®À» »ç¿ëÇϵµ·Ï Çϰí, DOMÀ» »ç¿ëÇÏ¿© CSS ¼Ó¼ºÀ» ÀÚ¹Ù½ºÅ©¸³Æ®·Î ÃʱâÈ­ÇÕ´Ï´Ù.

Keep in mind that according to the W3C Recommendation, the values returned by the style property of an element reflect static settings in the element's STYLE attribute only, not the total "computed style" that includes any inherited style settings from parent elements. Therefore, if you wish to read and write these properties from JavaScript through the DOM2, use one of these two approaches:

  • Place all of the element's static CSS declarations (if it has any) in the element's STYLE attribute.
  • Use no static CSS declarations for the element, and initialize its CSS properties from JavaScript through the DOM.
¿ä¼ÒÀÇ CSS À§Ä¡ÁöÁ¤ ¼Ó¼ºÀÇ W3C DOM2 ¹Ý¿µ
W3C DOM2 Reflection of an Element's CSS Positioning Properties

W3C DOM2ÀÇ style.left ¿Í style.top ¼Ó¼ºÀÌ ¹ÝȯÇÏ´Â °ªÀº CSS ´ÜÀ§ Á¢¹Ì»ç(¿¹¸¦ µé¾î "px")¸¦ Æ÷ÇÔÇÏ´Â ¹®ÀÚ¿­ÀÔ´Ï´Ù. Nav4ÀÇ  element.left ±×¸®°í IE4/5ÀÇ element.style.pixelLeft (±×¸®°í »óÀ§(top)¿¡ »óÀÀÇÏ´Â ¼Ó¼º)Àº Á¤¼ö(integer)¸¦ ¹ÝȯÇÕ´Ï´Ù. ±×·¸±â ´ë¹®¿¡, ¿©·¯ºÐÀÌ ÁÂÃø°ú »ó´Ü ¼³Á¤¿¡ ´ëÇÑ ¿ä¼ÒÀÇ ÀζóÀÎ ½ºÅ¸ÀÏÀ» Á¤¼ö·Î ÇÏ·Á¸é,  parseInt()¸¦ »ç¿ëÇÏ¿© ¹®ÀÚ¿­·ÎºÎÅÍ Á¤¼ö¸¦ ÇØ¼®Çϵµ·Ï ÇÕ´Ï´Ù. ¿ªÀ¸·Î ÁÂÃø°ú »ó´Ü¿¡ ´ëÇÑ ¿ä¼ÒÀÇ ÀζóÀÎ ¼³Á¤À» ÇÏ·Á¸é, Á¤¼ö°ª¿¡ ´ÜÀ§ ¹®ÀÚ¿­À» ÷°¡ÇÏ¿© ´ÜÀ§("140px"°ú °°ÀÌ)¸¦ Æ÷ÇÔ½ÃŲ ¹®ÀÚ¿­·Î ¸¸µéµµ·Ï ÇÕ´Ï´Ù.

The values returned by the W3C DOM2 style.left and style.top properties are strings that include the CSS unit suffix (such as "px"), whereas Nav4 element.left and IE4/5 element.style.pixelLeft (and the corresponding properties for top) return an integer. So, if you want to get the element's inline STYLE settings for left and top as integers, parse the integer from the string by using parseInt(). Conversely, if you want to set the element's inline STYLE settings for left and top, make sure to construct a string that includes the unit (such as "140px") by appending the unit string to the integer value.

DOMÀ» »ç¿ëÇÑ ¿ä¼ÒÀÇ ¿ø¹® º¯°æ

Changing an Element's Text Using the DOM

¿ä¼ÒÀÇ ½ÇÁ¦ ¿ø¹® ³»¿ëÀ» º¯°æÇÑ´Ù´Â °ÍÀº ¿¬»êÀ̶ó´Â ÀϹÝÀû ¼ö´Ü¿¡ ºñ±³ÇÏ¿© ±Ùº»ÀûÀ¸·Î º¯È­µÇ¾î¿Ô½À´Ï´Ù. °¢ ¿ä¼ÒÀÇ ³»¿ëÀº ÀÚ½Ä ¸¶µð(child node)·Î Âɰ³Á®¼­ Æò¹®°ú ÇÏÀ§¿ä¼Ò¸¦ ±¸¼ºÇÕ´Ï´Ù. ¿ä¼ÒÀÇ ¿ø¹®À» º¯°æÇϱâ À§ÇØ, ÇØ´ç ÀÛ¼º¹®Àº ÇØ´ç ¸¶µð(node)¿¡¼­ 󸮵˴ϴÙ.

Changing the actual text content of an element has changed substantially compared to the normal means of operation. Each element's content is broken up into a set of child nodes, consisting of plain text and subelements. In order to change the text of the element, the script operates on the node

¸¶µð(node) ±¸Á¶¿Í Áö¿øÇÏ´Â ¹æ½Ä(method)Àº DOM level 1 ±Ç°í»çÇ׿¡ Á¤ÀǵǾî ÀÖ½À´Ï´Ù.

The node structure and supporting methods are defined in the W3C DOM level 1 recommendation.

ÇØ´ç ¿ä¼Ò°¡ ÇÏÀ§¿ä¼Ò¾øÀÌ ±×³É ¿ø¹®¸¸ °¡Áø´Ù¸é, element.childNodes[0]·Î »ç¿ëµÇ´Â ÇϳªÀÇ ÀÚ½Ä ¸¶µð(child node)¸¦ °¡Áý´Ï´Ù.  element.innerText´Â  element.childNodes[0].nodeValue¸¦ ¾µ ¼öµµ ÀÖ½À´Ï´Ù.

If the element has no subelements, just text, then it (normally) has one child node, accessed as element.childNodes[0]. The rough equivalent of element.innerText is element.childNodes[0].nodeValue.

´ÙÀ½ÀÇ ¿¹Á¦´Â HTML ÆÄÀÏ¿¡ ÀÌ¹Ì Á¸ÀçÇÏ´Â SPAN ¿ä¼ÒÀÇ ¿ø¹®À» ¼öÁ¤ÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁÖ°í ÀÖ½À´Ï´Ù.

The following examples show how to modify the text of a SPAN element that already exists in the HTML file.

<body>
  <P>Papa's got <SPAN id="dynatext">a lot of nerve</SPAN>!</P>
  <script type="text/javascript">
    // SPAN ¿ä¼Ò¸¦ ÂüÁ¶ÇÕ´Ï´Ù.
    var span_el = document.getElementById("dynatext");
    // span_el.innerText = "a brand new bag" ó¸®ÇÕ´Ï´Ù.
    var new_txt = document.createTextNode("a brand new bag");
    span_el.replaceChild(new_txt, span_el.childNodes[0]);
    // ¸¶Âù°¡ÁöÀÎ µ¥, childNodes[0]°¡ ¿ø¹®¸¶µð°¡ ¾øÀ¸¸é
    // ´Ù¼Ò´Â À§ÇèÇØ¼­ ¿øÇÏ´Â ÀÛ¾÷ÀÌ µÇÁö¾Ê°Ô µË´Ï´Ù.
    // alternate, slightly more dangerous implementation
    //   (will not work if childNodes[0] is not a text node)
    span_el.childNodes[0].nodeValue = "a brand new bag";
    // span_el.innerHTML = "a brand <b>new</b> bag" ó¸®ÇÕ´Ï´Ù
    var new_el = document.createElement(span_el.nodeName);
    new_el.appendChild(document.createTextNode("a brand "));
    var bold_el = document.createElement("B");
    bold_el.appendChild(document.createTextNode("new"));
    new_el.appendChild(bold_el);
    new_el.appendChild(document.createTextNode(" bag"));
    span_el.parentNode.replaceChild(new_el, span_el);
  </script>
</body>

ù¹øÂ° ¿¹Á¦´Â SPAN ³» ¿ø¹®À» ¹Ù²Ù´Â »ó´ëÀûÀ¸·Î ´Ü¼øÇÑ ¹æ¹ýÀ» º¸¿©ÁÖ´Â °ÍÀ¸·Î ¿ø¹®À» »õ·Î¿î ¿ø¹® ¸¶µð·Î ´ëüÇÏ´Â °ÍÀÔ´Ï´Ù. ¿©±â¼­ ÀüÀç´Â SPANÀÌ ´Ü ÇϳªÀÇ ¿ø¹® ÀÚ½Ä(child)À» °¡Áö´Â °ÍÀ¸·Î, ÄÚµå´Â Âü(true)ÀÌ ¾Æ´Ï¶óµµ ÀÛµ¿ÇÏÁö¸¸, ±× °á°ú´Â ¿¹»óÇÒ ¼ö ¾ø´Ù´Â °ÍÀÔ´Ï´Ù.

The first example shows the relatively simple method of replacing the text in the SPAN by substituting a new text node for the original. The assumption here is that the SPAN has a single, text child; the code would work even if that were not true, but the results might be unexpected.

µÎ¹øÂ° ¿¹Á¦´Â µ¿ÀÏÇÑ ÀÛ¾÷À» ¼öÇàÇÒ ¼ö ÀÖ´Â ´õ ÀϰüµÇÁö¸¸ ¼øÂ÷Àû´ëÀÔ(brute-force) ±â¼úÀ» º¸¿©ÁÖ´Â °ÍÀÔ´Ï´Ù. ¹àÈù ¹Ù´ë·Î, ù¹øÂ° Àڽĸ¶µð(child node)´Â ¿ø¹® ³ëµå°¡ ¾Æ´Ï¶ó¸é, ÀÌ ÀÛ¾÷Àº ÀÛµ¿ÇÏÁö ¾Ê°Ô µË´Ï´Ù. ºñ·Ï ÇÏÀ§¿ä¼ÒÀÇ ¸¶µð°¡ nodeValue°¡ ÀÖ´õ¶óµµ, ÇØ´ç ÇʵåÀÇ ³»¿ëÀº ¹®¼­¿¡ Ç¥½ÃµÇÁö¾Ê°Ô µË´Ï´Ù.

The second example shows a more concise but brute-force technique of accomplishing the same thing. As noted, if the first child node is not a text node, this action will not work: altho subelement nodes have a nodeValue, the contents of that field are not displayed in the document.

¸¶Áö¸· ¿¹Á¦´Â innerHTML¼³Á¤°ú °°Àº ±â¼úÀ» º¸¿©ÁÝ´Ï´Ù. ù¹øÂ°´Â »õ·Î¿î ¿ä¼Ò¸¦ ±¸¼ºÇÏ´Â µ¥, ¿ø·¡¿Í °°Àº Çü½Ä(span)À» »ý¼ºÇÕ´Ï´Ù. ´ÙÀ½À¸·Î ÃÖÃÊ ¿ø¹® ¸¶µð, ±× ÀÚ½ÅÀÇ ¿ø¹®¸¶µð¸¦ °¡Áö´Â B ¿ä¼Ò, ±×¸®°í ¸¶Áö¸· ¿ø¹® ¸¶µð 3°³¸¦ Ãß°¡ÇÕ´Ï´Ù.  ±×¸®°í³ª¼­ ÀÛ¼º¹®Àº SPAN ¿ä¼ÒÀÇ ºÎ¸ð(P ¿ä¼Ò)¿¡ Á¢±ÙÇØ¼­, Àڽĸ¶µðÀÇ ºÎ¸ð ¸ñ·Ï¿¡¼­ ¿ø·¡ÀÇ SPAN ´ë½Å¿¡ »õ·Î¿î ¿ä¼Ò¸¦ »ç¿ëÇÏ°Ô µË´Ï´Ù. 

The final example shows a technique equivalent to setting innerHTML. First, it constructs a new element, created as the same type (SPAN) as the original. Next it adds three nodes: an initial text node, a B element with its own text node, anda final text node. The script then accesses the SPAN element's parent (the P element), and substitutes the new element for the original SPAN in the parent's list of child nodes.

¹®¼­ÀÇ ³»¿ëÀ» ¼öÁ¤Çϱâ À§ÇÏ¿© ÀÛ¼º¹®À» ¹Ù²Û´Ù´Â °ÍÀº »ç¼ÒÇÑ ÀÏÀº ¾Æ´Õ´Ï´Ù. ÀÌ·± º¯È¯ÀÇ ÀÕÁ¡Àº ³×½ºÄÉÀÌÇÁ 6/7 ±×¸®°í ´Ù¸¥ °ÔÄÚ ±â¹Ý ÇÁ·Î±×·¥°ú °°Àº Çö´ëÀûÀ̸ç W3C DOMÀ» µû¸£´Â ºê¶ó¿ìÀú¿¡¼­ ÀÛµ¿ÇÒ °ÍÀ̶ó´Â Á¡ÀÔ´Ï´Ù. ±×·¯³ª ȣȯ¼ºÀ» ¿ªÇàÇÏ·Á°í ÇÏ¸é ´ÙÁßÇ÷§Æû ¹®Á¦ÇذáÀ» Áö¿¬½Ãų»Ó¸¸ ¾Æ´Ï¶ó ¾ÇÈ­½Ãų °ÍÀÔ´Ï´Ù.

It should be clear that translating scripts to modify document content is not a trivial undertaking. The benefit of such a conversion is that the script will work in modern, W3C DOM-compliant browsers such as Netscape 6/7 and other Gecko-based programs. Requirements of backward compatibility, however, will not only prolong but worsen the difficulties of dealing with multiple platforms.

ºê¶ó¿ìÀú/Ç÷§Æû µ¶¸³ ÆäÀÌÁö °³¹ß

Developing Cross Browser/Cross Platform Pages

¡¡

Å©·Î½º Ç÷§Æû°ú DHTML °³¹ßÀ» À§ÇÑ Áß¿äÇÑ ½ÇõÀº ¿©·¯ºÐÀÇ ÆäÀÌÁö¸¦ º¸´Â ºê¶ó¿ìÀúÀÇ ´É·ÂÀ» °áÁ¤ÇÒ ¼ö ÀÖ°Ô ÇÏ´Â °ÍÀÔ´Ï´Ù. ¿©·¯ºÐÀº ¿À·ù¸¦ ÇÇÇØ¾ßÇϰí, °¡´ÉÇÑ ±¤¹üÀ§ÇÑ »ç¿ëÀÚ¿¡°Ô ¿©·¯ºÐÀÌ ÀÛ¼ºÇÑ ÀÛ¼º¹®À» ºÐ¸íÇÏ°Ô Àü´ÞÇÒ ¼ö ÀÖÀ¸¸é ÇÒ °ÍÀÔ´Ï´Ù.

An important practice for doing cross-platform and DHTML development is to able to determine at runtime the capabilities of the browser that are viewing your page. You need to avoid errors, and may want to ensure your script reaches as wide an audience as possible.

°øÅëÀûÀ¸·Î »ç¿ëµÇ´Â ÇѰ¡Áö ¹æ¹ýÀº ºê¶ó¿ìÀú¸¦ ¾Ë¾Æ³»¼­, ºê¶ó¿ìÀúÀÇ ´É·Â¿¡ ¸Â´Â ¼ö´ÜÀ» Á¦°øÇÏ´Â °ÍÀε¥, À̰ÍÀº ¹®Á¦°¡ ¸¹½À´Ï´Ù. ÇØ´ç ÆäÀÌÁö¸¦ ¹æ¹®ÇÏ´Â ¸ðµç ÇöÀçÀÇ ºê¶ó¿ìÀúÀÇ ´É·ÂÀ» ¾Ë¾Æ¾ß Çϱ⵵ Çϸç, ±×¿¡ ¸Â´Â ÀûÀýÇÑ ÄÚµå¶ó´Â °ÍÀÌ ¾ÕÀ¸·ÎÀÇ ºê¶ó¿ìÀú¿¡ ÀϾ ÀÏÀ» ¾È´Ù°Å³ª ¾ÈÀü¿¹¹æ¼­ºñ½º(safe fallback service)¸¦ Á¦°øÇÏ´Â µ¥ ¸¸Á·ÇÑ´Ù´Â °¡Á¤À» µÎ°íÀÖ°í, ¹«¾ùº¸´Ù ºê¶ó¿ìÀú¸¦ ¾Ë¾Æ³¾ ¼ö ÀÖ¾î¾ß ÇÑ´Ù´Â °ÍÀÔ´Ï´Ù.

One process, commonly used is to attempt to identify the browser, and have the user at design time decide what that means by way of the capabilityies of the browser, this is fraught with problems, it requires the user to have knowledge of the capabilities of all current browsers that may visit the page, and code appropriately for them, it requires the user to make assumptions about what will happen with future browsers, or be content with giving them a safe fallback service, and it requires users to be able to identify browsers in the first place.

ÀÌ·± 󸮹æ¹ýÀ» °£È¤ "ºê¶ó¿ìÀú ½º´ÏÇÎ(browser sniffing)"¶ó°í ÇÏ´Â µ¥, ºê¶ó¿ìÀúÀÇ ¹öÀü°ú Çü½ÄÀ» Á¡°ËÇÏ´Â ECMAScript ÇÔ¼ö·Î ´ë°³ 󸮵Ǵ °ÍÀ̸ç, ÇÊ¿äÇÏ´Ù¸é, ´Ù¸¥ ÇÔ¼ö¸¦ »ç¿ëÇϰųª ´Ù¸¥ ÆäÀÌÁö ¶Ç´Â À¥ÆäÀÌÁö¸¦ °¡¸®Å°µµ·Ï ÇÏ´Â ¹æ½ÄÀÔ´Ï´Ù. (±×·¯³ª À̰ÍÀº ¸µÅ©, ºÏ¸¶Å©, °Ë»ö¿£Áø, ¶Ç´Â "À߸øµÈ" ºê¶ó¿ìÀú ij½Ã¸¦ ÅëÇØ¼­ ÇØ´ç ÆäÀÌÁö¸¦ µé¾î°¥ ¼ö Àֱ⠶§¹®¿¡ ¾ÈÀüÇÑ ¹æ¹ýÀº ¾Æ´Õ´Ï´Ù.)

This process, often referred to as "browser sniffing," is usually handled by ECMAScript functions that test the version and type of the browser and, if necessary, use different functions or point the user to different pages or web content (This is very dangerous though as people may enter the page through a link, bookmark, search engine, or cache with a "wrong" browser). The following is a short list of sniffing functions for different browsers:

ÀÎÅͳÝÀͽºÇ÷η¯ ¹öÀü °¨Áö

Internet Explorer Version Detection

appVer = navigator.appVersion;
ver = parseFloat(appVer); // ³×½ºÄÉÀÌÇÁ¿Í ´Ù¸¥ ºê¶ó¿ìÀú
iePos = appVer.indexOf('MSIE');
if (iePos != -1)
   ver = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));

ºê¶ó¿ìÀú ½º´ÏÇÎ ÄÚµå

Browser Sniffing Code

ÀÌ ½º´ÏÇÎ Äڵ忡¼­, navigator °´Ã¼´Â ¹öÀü¿¡ ´ëÇÑ ½ÅÈ£¸¦ Àü´ÞÇÕ´Ï´Ù. ÇØ´ç ¹öÀüÀÌ "6"À̸é, ºê¶ó¿ìÀú´Â ³×½ºÄÉÀÌÇÁ 6À̶ó°í »ý°¢ÇÏ°Ô µË´Ï´Ù. ±×·¸Áö ¾Ê°í, ¼Ó¼º ºÎºÐÀ¸·Î "MSIE" ¹®ÀÚ¿­ÀÌ ¹ß°ßµÇ¸é, ÇØ´ç ºê¶ó¿ìÀú´Â IE5°¡ µÇ´Â °ÍÀÌÁÒ. 

In this sniffing code, the navigator object is interrogated for its version. If the version is "6", then the browser is understood to be Netscape 6. Otherwise, if the "MSIE" string is found as part of the property, then the browser is IE5.

if (navigator.appVersion.charAt(0) == "5")
{
   if (navigator.appName == "Netscape")
   {
      isNav6 = true
      alert('NS6')
   }
}
else if (navigator.appVersion.indexOf("MSIE") != -1)
    isIE = true alert('IE')

ÀÌ·± ½ÄÀÇ Á¡°ËÀº ±×·±´ë·Î ÀÛµ¿ÇÒ ¼ö ÀÖÁö¸¸, ³ÃöÇÑ µ¶ÀÚ¶ó¸é IE6.0, ¿ÀÆä¶ó ¶Ç´Â ´Ù¸¥ ¹öÀüÀÇ ºê¶ó¿ìÀúÀº ¾î¶»°Ô ÇÏ´À³Ä°í »ý°¢ÇÒ Áö ¸ð¸¨´Ï´Ù. »õ·Î¿î ºê¶ó¿ìÀú°¡ ³ª¿À°Ô µÇ¸é, ÀÌ¿¡ µû¶ó Äڵ带 ¾÷µ¥ÀÌÆ®ÇØ¾ß ÇÕ´Ï´Ù. ÀÌ·± ¹æ¹ýÀº ºê¶ó¿ìÀú¿¡ ¸ÂÃ߾ ÀûÀýÇÑ ÀüȯÀ» ÇÒ ¼ö ÀÖ°Ô´Â ÇÕ´Ï´Ù.

While this kind of checking can work in a crude sense, sharp readers may wonder what happens with IE6.0, Opera 5.0 or other version 5 browsers. As new browsers are released, it becomes necessary to make updates to code such as this, which attempts to narrow down the client and make the appropriate switches.

ÀÌ·± Á¢±Ù¹æ½ÄÀÇ ´Ù¸¥ ¹®Á¦´Â ºê¶ó¿ìÀúÀÇ ½Çü°¡ À§Á¶µÉ ¼ö ÀÖ´Â µ¥, ¸¹Àº ´õ¸¹Àº Çö´ëÀûÀÎ ºê¶ó¿ìÀú¿¡´Â navigator.appVersion ¸¦ »ç¿ëÀÚ°¡ ¼³Á¤ÇÒ ¼ö ÀÖ´Â ¹®ÀÚ¿­À̱⠶§¹®ÀÔ´Ï´Ù. ¸ðÁú¶ó´Â "general.useragent.override"¶ó´Â ȯ°æ¼³Á¤À» ÀÌ¿ëÇϰí ÀÖ°í ¿ÀÆä¶ó´Â ¸Þ´º¿¡¼­ ÀÌ ¹®ÀÚ¿­À» ¼³Á¤ÇÒ ¼ö ÀÖÀ¸¸ç IE´Â À©µµ¿ìÁî ·¹Áö½ºÆ®¸®¸¦ »ç¿ëÇϰí ÀÖ½À´Ï´Ù. Áï »ç¿ëÀÚ³ª ºê¶ó¿ìÀú ¹èÆ÷ÀÚ´Â ±×µéÀÌ ¿øÇÏ´Â °ÍÀ» ÀÌ ¹®ÀÚ¿­¿¡ ÀÔ·ÂÇÒ ¼ö ÀÖ´Â µ¥, ÀÌ·¸°Ô µÇ¸é ÀÛ¼ºµÈ Äڵ尡 ¾û¶×ÇÑ ºê¶ó¿ìÀú¿¡ ´ëÇØ ½ÇÇàÇÒ ¼ö ÀÖ°Ô µË´Ï´Ù. Á¤È®ÇÏ°Ô ÀÎ½ÄµÈ ºê¶ó¿ìÀúÁ¶Â÷µµ ¿øÇÏ´ø´ë·Î ÀÛµ¿ÇÏÁö ¾Ê´Â °æ¿ì ¸¹½À´Ï´Ù.(¾Æ·¡ DOM implementation¸¦ Âü°íÇϼ¼¿ä)

The other problem with this approach is that the browser identity can be "spoofed," because in many more modern browsers, navigator.appVersion is a user configurable string. Mozilla uses the preference "general.useragent.override"; Opera allows you to set this string in a menu, and IE uses the Windows registry. A user or browser distributor can put what they want in the string, and this may trick your code into executing for the wrong client. Moreover, there are many cases where even the accurately-identified browser does not perform as it is reputed to (see DOM implementation notes below).

°´Ã¼ °¨Áö

Using Object Detection

"ºê¶ó¿ìÀú ½º´ÏÇÎ"ÀÌ ½Å·ÚÇÒ ¼ö ¾øÀ¸¸ç ³­Á¦°¡ ÀÖ´Ù¸é, ´Ù¸¥ ºê¶ó¿ìÀú¿¡ ´ëÇØ ¾ÈÀüÇÏ°Ô ¾î¶»°Ô Äڵ带 ÀÛ¼ºÇØ¾ß Çϴ°¡? ÇѰ¡Áö ´ë¾ÈÀº "°´Ã¼ °¨Áö"¸¦ »ç¿ëÇÏ´Â °ÍÀÔ´Ï´Ù. °´Ã¼ °¨Áö¸¦ »ç¿ëÇÑ´Ù°í ÇÒ¶§´Â, ºê¶ó¿ìÀú¿¡¼­ ¸ÕÀú Å×½ºÆ®ÇÑ Áö¿ø±â´É¸¸À» ó¸®ÇÏ´Â °ÍÀÔ´Ï´Ù. ÀÌ ¹æ½ÄÀº ¸ðµç °ÍÀÌ ¾Æ´Ï¶ó ÀÛ¼ºÇÑ ÄÚµåÀÇ ±â´ÉÀÌ ºê¶ó¿ìÀú¿¡¼­ Áö¿øµÇ´Â Áö¸¦ Å×½ºÆ®¸¸ÇÏ¸é µË´Ï´Ù.

So if "browser sniffing", can be unreliable and difficult, how do you code safely for different browsers? One alternative is to use "object detection." When you use object detection, you only implement those features whose support you have first tested on the client. This method has the advantage of not requiring you to test for anything except whether the particular features you code are supported on the client.

°´Ã¼ °¨Áö´Â ¾Æ·¡ ¿¹Á¦¿¡ Àß ¼³¸íµÇ¾î ÀÖ½À´Ï´Ù:

Object detection is best illustrated by an example:

if (document.getElementById &&
      document.getElementById(id) &&
      document.getElementById(id).style)
   document.getElementById(id).style.visibility="hidden";

document.getElementById ¿¡ ´ëÇÑ ÀÌ·± ¹Ýº¹µÈ È£ÃâÀº °¡Àå È¿°úÀûÀÎ °ÍÀº ¾Æ´Ï´õ¶óµµ ºê¶ó¿ìÀúÀÇ DOM implementation¿¡ ÀÖ¾î Æ¯Á¤ °´Ã¼³ª ±â´ÉÀ» üũÇÒ ¼ö ÀÖ´Â °ÍÀÌÁö¸¸, ¾î¶»°Ô °´Ã¼°¨Áö°¡ ²Ï ±ò²ûÇÏ°Ô Ã³¸®ÇÏ´Â Áö¸¦ º¸¿©ÁÝ´Ï´Ù. (´õ ÃÖÀûÈ­µÈ ´ÙÀ½ÀÇ µÎ°¡Áö ¿¹Á¦¿Í ¾Æ·¡ÀÇ DOM hasFeature¸¦ Âü°íÇϼ¼¿ä), 

These repeated calls to document.getElementById are not the most efficient may to check for the existence of particular objects or features in the browser's DOM implementation (see the next two examples for more optimized versions and see the DOM hasFeature discussion below), but they illustrate how object detection works quite clearly.

»ó´ÜÀÇ ifÀýÀº ¹®¼­°´Ã¼¿¡ Àִ ȣÃâµÈ getElementById °´Ã¼°¡ ÀÖ´Â Áö ã´Â °ÍÀε¥, ºê¶ó¿ìÀú¿¡¼­ DOMÀ» Áö¿øÇÏ´Â °¡Àå ±âº»ÀûÀÎ °ÍÁß ÇϳªÀÔ´Ï´Ù. ¸¸¾à ÀÖ´Ù¸é, ÇØ´ç ÄÚµå´Â getElementById(id) °¡ ¿ä¼Ò¸¦ ¹ÝȯÇÏ´Â Áö º¸°í¼­, style °´Ã¼¸¦ Á¡°ËÇÕ´Ï´Ù. style °´Ã¼°¡ ÇØ´ç ¿ä¼Ò¿¡ ÀÖ´Ù¸é, ÀÌ·¸°ÔÇØ¼­ °´Ã¼ÀÇ visibility ¼Ó¼ºÀ» ¼³Á¤ÇÏ´Â °ÍÀÌÁÒ. »ç¿ëÀÚ°¡ À̰ÍÀ» ¹Ìó¸® ¼Ó¼ºÀ¸·Î ¼³Á¤ÇßÀ»Áö¶óµµ ºê¶ó¿ìÀú´Â ¿À·ù¸¦ ÀÏÀ¸Å°Áö¾ÊÀ» °ÍÀ̱⠶§¹®¿¡ visibility ¼Ó¼º ÀÚü°¡ Á¸ÀçÇÏ´Â Áö Á¡°ËÇÒ Çʿ䰡 ¾ø°Ô µË´Ï´Ù.

The top-level if clause looks to see if there's an object called getElementById on the document object, which is the one of the most basic levels of support for the DOM in a browser. If there is, the code sees if getElementById(id) returns an element, which it then checks for a style object. If the style object exists on the element, then it sets that object's visibility property. The browser will not error if you set this unimplemented property, so you don't need to check that the visiblity property itself exists.

Generally object detection code like this should be placed in functions so that your code doesn't become too complicated or unmaintainable:

function hideElement(element_id)
{
   if (document.getElementById &&
         document.getElementById(element_id) &&
         document.getElementById(element_id).style)
      document.getElementById(element_id).style.visibility="hidden";
}

// ¿¹Á¦:
// <button onclick="hideElement('d1');">hide div</button>
// <div id="d1">div one</div>

¾î´À ºê¶ó¿ìÀú°¡ DOM ¹æ½ÄÀÇ getElementById ¸¦ °¡Áö°í ÀÖ´Â Áö ¾Ë °Í¾øÀÌ, ¹Ù·Î ±× ¹æ½ÄÀ» Å×½ºÆ®ÇÑ °ÍÀÔ´Ï´Ù. ÀÌ ¹æ½ÄÀ» »ç¿ëÇÑ´Ù¸é, ¹Ì·¡ÀÇ ¹èÆ÷ÆÇ°ú ¿©·¯ºÐÀÌ ¾ËÁö¸øÇÏ´Â ºê¶ó¿ìÀúÀÇ userAgent ¹®ÀÚ¿­À» Æ÷ÇÔÇÑ ¸ðµç ºê¶ó¿ìÀú´Â ¿©·¯ºÐÀÌ ÀÛ¼ºÇÑ Äڵ带 ó¸®ÇÒ °ÍÀÔ´Ï´Ù.

Now, instead of needing to know which browsers have the DOM method getElementById, you test for that very method. Using this method, you ensure that all browsers--including future releases and browsers whose userAgent strings you don't know about--will continue working with your code.

±×·±µ¥ ÀÌµé ¿¹Á¦ ¾î´À °Íµµ ³×ºñ°ÔÀÌÅÍ 4¿Í ÀͽºÇ÷η¯ 4 ºê¶ó¿ìÀú¿¡´Â ÀÛµ¿ÇÏÁö ¾Ê´Â´Ù´Â »ç½ÇÀÔ´Ï´Ù. ÀÌµé ±¸¹öÀüÀÇ ºê¶ó¿ìÀú¿¡¼­ ÀÛµ¿ÇÏ´Â °´Ã¼°¨Áö Äڵ带 ÀÛ¼ºÇÏ·Á¸é, ¶Ç´Ù¸¥ Á¡°Ë ·¹º§À» Ãß°¡ÇØ¾ß ÇÏ´Â µ¥, ¸»ÇÏÀÚ¸é Ç¥ÁØÀûÀÎ document.getElementById ¸¦ Áö¿øÇÏÁö¾Ê´Â ºê¶ó¿ìÀú¿¡ Àû´çÇÑ °´Ã¼ Âü°íÀڷḦ Á¦°øÇÏ´Â °ÍÀÔ´Ï´Ù. ¹æ¹ýÀº °¢°¢ÀÇ ºê¶ó¿ìÀú Ç÷§Æû¿¡¼­ document.getElementById ´ë½Å¿¡ IEGetElementById¿Í NN4GetLayerById ¶ó´Â µÎ°¡Áö ÇÔ¼ö¸¦ È£ÃâÇÏ´Â °ÍÀÔ´Ï´Ù. 

Note that neither of these foregoing examples works for Navigator 4 and Internet Explorer 4 browsers. To create object detection code that works on these older browsers, it's necessary to add another level of checking, where browsers that do not support the standard document.getElementById are given some means of returning the appropriate object reference. The two functions at the top of this listing, IEGetElementById and NN4GetLayerById are called in place of document.getElementById on their respective browsers platforms.

function IE4GetElementById(id)
{
   return document.all[id];
}
function NN4GetLayerById(id)
{
  // see xbStyle on the evangelism site
  // for details on a possible implementation
}
if (document.layers)
   document.getElementById = NN4GetLayerById;
else if (document.all && !document.getElementById)
   document.getElementById = IE4GetElementById;
function getStyleObject(id)
{
   var elm = null;
   var styleObject = null;
   if (document.getElementById)
      elm = document.getElementById(id);
   if (elm)
   {
      if (elm.style)
         styleObject = elm.style;
      else if (document.layers)
         styleObject = elm;
   }
  return styleObject;
}
function hideElement(id)
{
  var styleObject = getStyleObject(id);
  if (styleObject)
    styleObject.visibility = 'hidden';
}

DOM implementation °´Ã¼ »ç¿ë

Using the DOM implementation Object

DOM1 ȣȯ ºê¶ó¿ìÀú´Â document.implementation.hasFeature()¿¡ ÀáÀçÀûÀ¸·Î À¯¿ëÇÑ °´Ã¼¸¦ ´ã°íÀֱ⵵ Çѵ¥, ƯÁ¤ÇÑ ±â´ÉÀ̳ª Áö¿ø·¹º§À» ÁúÀÇÇÏ´Â µ¥ Âü(true)/°ÅÁþ(false)¸¦ ¹ÝȯÇÏ´Â °ÍÀÔ´Ï´Ù.

DOM 1 compliant browsers also contain a potentially useful object in document.implementation.hasFeature(), which should return true/false on being queried for a specific feature or level of support.

if (document.implementation &&
      document.implementation.hasFeature &&
      document.implementation.hasFeature("DOM","2.0"))
   alert("DOM version 2.0 support available");
else
   alert("No DOM 2.0 support.");

ÀÌ·± Á¢±Ù¹æ½ÄÀº ºÒÇàÇϰԵµ Ç×»ó ½Ç¿ëÀûÀÌÁö´Â ¸øÇÕ´Ï´Ù. DOM implementation Á¤º¸°¡ À߸ø Àü´ÞµÉ ¼ö Àְųª ´Ù¸¥ ºê¶ó¿ìÀú¿¡¼­ À߸ø ó¸®µÉ ¼ö Àֱ⠶§¹®ÀÔ´Ï´Ù(³×½ºÄÉÀÌÇÁ 6ÀÇ Ã¹¹èÆ÷ÆÇ¿¡¼­ ECMAScript Áö¿øÀÌ ±×·± ¿¹ÀÔ´Ï´Ù). ÀϺΠºê¶ó¿ìÀú¿¡¼­´Â ±â´ÉÀ» Áö¿øÇÏÁöµµ implementation.hasfeature() ¹æ½Ä ÀÚü¸¦ Áö¿øÇÏÁö ¾Ê±â ¶§¹®¿¡ ÀÌ·± ¹æ½ÄÀÌ °ÅÀÇ ¾µ¸ð¾ø°Ô µÉ ¼ö ÀÖ½À´Ï´Ù. hasFeature()¸¦ »ç¿ëÇÑ´Ù¸é,À§ÀÇ object detection ¿¹Á¦¿¡¼­Ã³·³ implementation °´Ã¼¿Í hasFeature() ¹æ½ÄÀ» »ç¿ëÇØ¾ß ÇÑ´Ù´Â °ÍÀ» ±â¾ïÇØµÎ¼¼¿ä.

This approach isn't always practical, unfortunately, since DOM implementation information can be misleading or false on different browsers (ECMAScript support in the first release of Netscape 6 is a case in point.) Some browsers have support for features but not for the implementation.hasfeature() method itself, which can render this method nearly useless. If you do use hasFeature(), remember to use object detection on the implementation object and hasFeature() method, as in the object detection example above.

±¸¼º¿ä¼Ò¿Í Ç÷¯±×ÀÎ

Components and Plug-ins

¸ðÁú¶ó´Â ±¸¼º¿ä¼Ò¿Í ¸ðµç Á¾·ùÀÇ ÆÄÀÏÀ» ¼³Ä¡ÇÏ°í ¾÷µ¥ÀÌÆ®Çϱâ À§ÇØ ´ÜÀÏ ¾ÐÃà Æ÷¸ËÀ» »ç¿ëÇÕ´Ï´Ù. XPI Æ÷¸ËÀº ÀÎÅÍ³Ý ÀͽºÇ÷η¯ 4ÀÌ»ó ¹öÀü¿¡¼­ ½º¸¶Æ®¾÷µ¥ÀÌÆ® ¹ÙÀ̳ʸ®¿Í ´Ù¿î·Îµå .cab ÆÄÀÏ ´ë½Å¿¡ .jar¶ó´Â ÆÄÀÏÀ» »ç¿ëÇÕ´Ï´Ù.

Mozilla uses a single archive format to install and update components and files of all kinds. This format, the XPI format, replaces the use of .jar files for SmartUpdates of binaries and .cab files for download of binaries on Internet Explorer 4 and beyond.

XPI Æ÷¸ËÀÇ »ùÇÃÀº ´ÙÀ½ ¸µÅ©¿¡¼­ º¼ ¼ö ÀÖ½À´Ï´Ù:
ftp://ftp.netscape.com/pub/netscape6/english/6.0/windows/win32/xpi/

Á¦¿ÜµÈ ¿ä¼Ò ´ëü
Navigator 4 .jar ÆÄÀϰú IE4+ .cab ÆÄÀÏ XPInstallÀ» Áö¿øÇÏ´Â .xpi ÆÄÀÏ

¶ÇÇÑ, LiveConnect¸¦ ÅëÇØ¼­ ÀÚ¹Ù½ºÅ©¸³Æ®ÀÇ Ç÷¯±×ÀÎ Java API¸¦ È£ÃâÇÏ´Â Ç÷¯±×ÀÎ ±¸¼º¿ä¼Ò°¡ ÀÖ´Ù¸é, ¸ðÁú¶ó Ç÷¯±×ÀÎ API¸¦ Áö¿øÇϱâ À§Çؼ­ Ç÷¯±×ÀÎ °ø±ÞÀÚ°¡  Ç÷¯±×ÀÎÀ» ¾÷±×·¹À̵åÇØ¾ßÇÏ´Â Áö È®ÀÎÇϼ¼¿ä. ±×¸®°í ¾÷±×·¹À̵åµÈ Ç÷¯±× ¹èÆ÷ ÀÏÁ¤À» ã¾Æº¸·Á¸é Ç÷¯±×ÀÎ °ø±ÞÀÚ¿¡°Ô ¿¬¶ôÀ» ÇØº¸¼¼¿ä.

Also, if you have plug-in content that calls a plug-in's Java API from JavaScript via LiveConnect, be aware that the plug-in vendor must upgrade their plug-in to support the Mozilla Plug-in API. Until then, these JavaScript calls within the content will fail silently. Contact the plug-in vendor to find out their schedule for releasing an upgraded plug-in.

º¯°æ³»¿ë ¿ä¾à

Summary of Changes

ÀÌ ´Ü¿øÀº ÀÌ ±Û¿¡¼­ ¼³¸íÇÑ ¸ðµç ¿ä¼Ò¿Í ¾÷µ¥ÀÌÆ® ¹æ¹ýÀ» Á¤¸®ÇÑ °ÍÀÔ´Ï´Ù. À̵é Ç׸ñ¿¡ ´ëÇÑ Àüü ³íÀǸ¦ »ìÆìº¸·Á¸é, ÇØ´ç ´Ü¿øÀ» Âü°íÇϼ¼¿ä.

This section outlines all of the element and practice updates described in this article. For a complete discussion of these items, see the sections in which they are described.

µ¶Á¡ ¶Ç´Â ÃßõÇÏÁö ¾Ê´Â ±â´É W3C ±â´É ¶Ç´Â ÃßõÇÏ´Â ´ëüǥÇö
Nav4 LAYER HTML 4.0 DIV
Nav4 ILAYER HTML 4.0 IFRAME
Nav4 LAYER SRC=, ILAYER SRC=, DIV SRC= HTML 4.0 IFRAME SRC=
IE2+ MARQUEE HTML 4.0 DIV plus scripting
Nav2+ BLINK CSS1 text-decoration:blink
IE2+ BGSOUND HTML 4.0 OBJECT
Nav 2+, IE3+ EMBED HTML 4.0 OBJECT
deprecated APPLET HTML 4.0 OBJECT
deprecated FONT HTML 4.0 SPAN plus
CSS1 color:,
text-face:, text-size:
deprecated CENTER CSS1 text-align:center
deprecated U, S, STRIKE CSS1 text-decoration: underline,
line-through
deprecated DIR, MENU HTML 4.0 UL
Nav4 document.layers[]
IE4/5 document.all
DOM level 1 document.getElementById()
Nav4 document.layers[id].document.write()
IE element.innerText, element.innerHTML
DOM Level 1 (Core) interface
Nav4 element.visibility = value;
IE4/5 element.style.visibility = value;
DOM level 2 element.style.visibility =
value;
Nav4 element.left
IE4/5element.style.pixelLeft
DOM level 2: parseInt(element.style.left)
Nav4 element.top
IE4/5 element.style.pixelTop
DOM level 2: parseInt(element.style.top)
Nav4 element.moveTo(x, y);
IE4/5 element.style.pixelLeft = x;
element.style.pixelTop = y;
DOM level 2:
  element.style.left = x + "px";
  element.style.top = y + "px";
Nav4 document.tags, document.ids, document.classes;
Nav4/IE4/5 document.elementName
DOM access methods
IE4/5 document.styleSheets[].addRule(selector, declaration);
Nav4 document.contextual()
DOM Level 2 CSS Interface
Navigator 4 .jar ÆÄÀϰú IE4+ .cab ÆÄÀÏ XPInstallÀ» À§ÇÑ XPI ÆÄÀÏ
Plug-ins using LiveConnect to access the Java API from JS Mozilla Plug-in API

Last modified October 3, 2002.
Ian Oeschger, Jim Ley, Mike Cowperthwaite