Event ¼ø¼­¿Í ÁöÁ¤ÇϱâGo to Event

À̺¥Æ® ¼ø¼­ È®ÀÎÇϱâ



Position element(layer)¿¡¼­ÀÇ À̺¥Æ®°¡ ÀϾ´Â ¼ø¼­´Â NN4´Â window-document-objectÀÔ´Ï´Ù. Áï »óÀ§¿¡¼­ ½ÃÀÛÇÏ¿© ÇÏÀ§·Î ³»·Á¿É´Ï´Ù. ¹Ý¸é¿¡, IE4´Â ¹Ý´ë ÀÔ´Ï´Ù. ÇÏÀ§¿¡¼­ »óÀ§·Î ¿Ã¶ó°©´Ï´Ù. ±×·¡¼­, layer°¡ layer¸¦ °¡Áö°í ÀÖÀ» ¶§, µ¿½Ã¿¡ µÎ°³ÀÇ À̺¥Æ®¸¦ È£ÃâÇϸé NN4´Â »óÀ§ºÎÅÍ IE´Â ÇÏÀ§ºÎÅÍ À̺¥Æ®°¡ ÀϾ´Ï´Ù. (nn4¿¡¼­ captureEvents(), routeEvent()·Î ÇßÀ» ¶§´Â Á¶±Ý ´Ù¸¨´Ï´Ù.) ¿©±â¼­ÀÇ ¼ø¼­´Â À̺¥Æ® Çîµé·¯¸¦ ¸»ÇÕ´Ï´Ù. ¸µÅ©·Î Ä¡¸é href="javascript:alert('HREF')" onClick="alert('click Event is triggered')" ¿¡¼­ onClickÀÌ ÀϾ´Â ¼ø¼­¸¦ ¸»ÇÕ´Ï´Ù.

NN4 layer¿¡¼­ À̺¥Æ®¸¦ ¼±¾ð ½Ã position element´Â </div>Åà ´ÙÀ½¿¡ <script></script>¿¡¼­ ¼±¾ðÇÕ´Ï´Ù. JavaScript·Î ¾î¶² À̺¥Æ®¸¦ °¡Áú ¼ö ÀÖ´Â Object¿¡ À̺¥Æ® Çîµé·¯¸¦ ÁöÁ¤ÇÒ ¶§´Â ±× Object°¡ ÆäÀÌÁö¿¡ ¸ÕÀú Ãâ·Â(load)µÇ¾î ÀÖ¾î¾ß ÇÕ´Ï´Ù. ¼ø¼­·Î Çϸé..

<div>CSS LAYER</div>
<script>LayerObject.À̺¥Æ®Çîµé·¯ = ÁöÁ¤ÇÔ¼ö</script> 
ÀÔ´Ï´Ù.

layer Çϳª¸¸ ÁöÁ¤ÇÒ ¶§´Â ÀÌ·¸°Ô ÇÒ ¼ö ÀÖÁö¸¸, layer°¡ ÀÚ½ÅÀÌ layer¸¦ °¡Áö°í ÀÖ´Ù¸é, °¡Àå »óÀ§ÀÇ layer´Â ÀÌ·¸°Ô À̺¥Æ® Çîµé·¯¸¦ ÁöÁ¤ÇÒ ¼ö Àִµ¥, ³»ºÎÀÇ layer´Â ÀÌ·¸°Ô ÇÒ ¼ö ¾ø½À´Ï´Ù. Áï, ¾Æ·¡ÀÇ ÄÚµå´Â ¾ÈµË´Ï´Ù.

1. <div id=parentLayer>parentLayer 
2. 	<div id=sonLayer>sonLayer</div> 
3. 	<script>document.parentLayer.document.sonLayer.onmouseover=someFunction</script> 
4. </div> 

5. <script>document.parentLayer.onmouseover=someFunction</script>
3¹ø ÁÙÀÌ ¿Ö ¾ÈµÇ³Ä ÇÏ°í »ý°¢ ÇÏ´Ù°¡ Á¦°¡ ³»¸° °á·ÐÀº, layer°¡ °¡Áö´Â ¸ðµç Object´Â layerÀÇ documentÀÔ´Ï´Ù. ±×¸®°í, document´Â windowÀÇ ObjectÀÔ´Ï´Ù. document´Â window ¹ØÀÇ ObjectÀ̱⠶§¹®¿¡ window°¡ Ãâ·ÂµÇ°í ³­ ´ÙÀ½ document°¡ ¿É´Ï´Ù. layerµµ ÇϳªÀÇ Ã¢(window)À̱⠶§¹®¿¡ âÀÌ ´Ù Ãâ·ÂµÇ¾î¾ß ³»ºÎÀÇ document¸¦ Ãâ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù. Áï, </div>·Î âÀÌ ´Ù Ãâ·ÂµÇ°í ³ª¼­¾ß layer°¡ °¡Áö´Â document(À§ÀÇ sonLayer)ÀÇ À̺¥Æ®¸¦ ¼³Á¤ÇÒ ¼ö ÀÖ½À´Ï´Ù.

..¶ó°í »ý°¢ Çߴµ¥, À̰ÍÀº BUG¶ó´Â ¸»µµ ÀÖ°í ¿ø·¡ ±×·¸´Ù´Â ¸»µµ ÀÖ½À´Ï´Ù. :)
¹ö±×¶ó¸é °¡Àå ½É°¢ÇÑ ¹ö±×Àεí.. ¹°·Ð ÇØ°áÃ¥Àº ÀÖ½À´Ï´Ù.

°á·ÐÀº layer¸¦ °¡Áö°í ÀÖ´Â layer°¡ Ãâ·ÂµÉ ¶§´Â °¡Àå »óÀ§ÀÇ layer(À§ÀÇ parentLayer)¸¸ À̺¥Æ® Çîµé·¯ onmouseover, onmouseout µÎ °³¸¦ °¡Áú ¼ö ÀÖÁö, ³»ºÎÀÇ ¾î¶² documentµµ À̺¥Æ® Çîµé·¯¸¦ ¼³Á¤ÇÒ ¼ö ¾ø½À´Ï´Ù. layerÀÇ µÎ À̺¥Æ® mouseOver, mouseOut ±×¸®°í body ÅÃÀÇ onLoad À̺¥Æ®·Î ÀÌ ¹®Á¦¸¦ ±Øº¹ÇÒ ¼ö ÀÖ½À´Ï´Ù.

IE4´Â ÇÏÀ§ÀÇ layer¿¡°Ôµµ ÁöÁ¤ÇÒ ¼ö ÀÖ½À´Ï´Ù. µû¶ó¼­, ÀÌ ÆäÀÌÁö´Â ÁÖ·Î NN4¿¡¼­ À̺¥Æ®Çîµé·¯¸¦ ÁöÁ¤ÇÏ´Â ³»¿ëÀÔ´Ï´Ù.


layer°¡ layer¸¦ °¡Áö°í ÀÖÀ» ¶§, ¿ÀÁ÷ ÃÖ»óÀ§ÀÇ layer¸¸ À̺¥Æ® Çîµé·¯(onMouseOver, onMouseOut)¸¦ °¡Áú ¼ö ÀÖÀ¸¹Ç·Î, ³»ºÎÀÇ layer´Â ´Ù¸¥ ¹æ¹ýÀ» »ç¿ëÇØ¾ß ÇÕ´Ï´Ù. Áï, Àüü ÆäÀÌÁö°¡ ´Ù Ãâ·ÂµÈ ÈÄ ÃÖ»óÀ§ÀÇ layerÀÇ onMouseOver¸¦ »ç¿ëÇÏ´Â ¹æ¹ýÀÔ´Ï´Ù. IE4´Â divÅÿ¡ ¸¹Àº À̺¥Æ®°¡ ÀÖÁö¸¸, NN4¿¡¼­´Â position:absolute(relative)¸¦ ÁöÁ¤ÇÑ CSS-layer ¶Ç´Â layer´Â onmouseOver, onmouseOut µÎ°¡Áö À̺¥Æ®¸¸ Áö¿øÇÕ´Ï´Ù. (ilayer, position:relative ´Â À̺¥Æ®¸¦ »ç¿ëÇÒ ¼ö ¾ø´Â ¹ö±×°¡ ÀÖ½À´Ï´Ù.)

onmove, onresize´Â windowÀÇ À̺¥Æ®ÀÌ°í ³ª¸ÓÁö´Â ¸ðµÎ documentÀÇ À̺¥Æ®ÀÔ´Ï´Ù.

·¹À̾î(css-p), document, window¿¡¼­ÀÇ »ç¿ë°¡´ÉÇÑ À̺¥Æ®

NN4´Â

  • ·¹À̾î : mouseover, mouseout
  • window : move, resize
  • document : À§ÀÇ 4°³ÀÇ À̺¥Æ®¿Í mousemove ÃÑ 5°³¸¦ Á¦¿ÜÇÑ ¸ðµç À̺¥Æ®.

    * mousemove´Â captureEvents()¿Í¸¸ °°ÀÌ »ç¿ëÇÏ´Â À̺¥Æ®, captureEvents()°¡ ÁöÁ¤ÇÑ objectÀÇ À̺¥Æ®ÀÌ´Ù.

    IE4´Â Åà º°·Î ³Ê¹« ¸¹Àº À̺¥Æ®¸¦ Áö¿øÇؼ­ ºÐ·ù°¡ ¾î·Æ½À´Ï´Ù.. SDK¸¦ ÂüÁ¶Çϼ¼¿ä..

    <script>
    function sonLayerEvent() {
    	alert("I am sonLayer");
    }
    function setEvent() {
    	alert("I am parentLayer");
    	this.document.sonLayer.onmouseover = sonLayerEvent; //(1)
    }
    </script>
    </head>
    <body>
    <div id=parentLayer style="position:absolute;">parentLayer
    	<div id=sonLayer style="position:absolute;">sonLayer</div>
    </div>
    <script>document.parentLayer.onmouseover=setEvent</script> 
    </body>
    
    ³»ºÎ layer¿¡ À̺¥Æ®¸¦ ÁöÁ¤ÇÏÁö ¾Ê¾Ò½À´Ï´Ù. ÆäÀÌÁö°¡ Ãâ·ÂµÈ ÈÄ »óÀ§ layerÀÎ parentLayer¿¡ ¸¶¿ì½º¸¦ °¡Á®°¡¸é ±× ¼ø°£, sonLayerÀÇ onmouseover À̺¥Æ® Çîµé·¯¿¡ sonLayerEvent() ÇÔ¼ö¸¦ ÁöÁ¤ÇÏ°í µ¿½Ã¿¡ ÇÔ¼ö¸¦ È£ÃâÇÕ´Ï´Ù. Áï, ¸ÕÀú "I am parentLayer"°¡ ³ª¿À°í sonLayer¿¡ À̺¥Æ®¸¦ ÁöÁ¤ÇÕ´Ï´Ù. ¸¶¿ì½º¸¦ Á¶±Ý¾¿ ¿òÁ÷¿©¼­ sonLayer¿¡ °¡Á®°¡¸é "I am sonLayer"°¡ ³ª¿É´Ï´Ù.

    ÁÖ¼® (1)ÀÇ this´Â parentLayer¸¦ ¸»ÇÕ´Ï´Ù. JavaScript·Î Object¿¡ À̺¥Æ® Çîµé·¯¸¦ ÁöÁ¤Çϸé HTML Åà ³»ºÎ¿¡¼­ ¼±¾ðÇÑ °Í°ú °°½À´Ï´Ù. Áï, this´Â ±× Object ÀÚ½ÅÀ» ¸»ÇÕ´Ï´Ù.

    À§ÀÇ ¼Ò½º´Â parentLayerÀÇ mouseoverÀ̺¥Æ®·Î ÇÏÀ§ÀÇ sonLayer¿¡°Ô mouseover À̺¥Æ®¸¦ ÁöÁ¤Çß½À´Ï´Ù. µû¶ó¼­, Ç×»ó "I am parentLayer"°¡ ³ª¿À°í ´ÙÀ½¿¡ "I am sonLayer"°¡ ³ª¿É´Ï´Ù.

    ¾Æ·¡ÀÇ ¼Ò½º´Â bodyÀÇ onLoad À̺¥Æ® Çîµé·¯·Î °¢°¢ layerÀÇ À̺¥Æ®¸¦ ÁöÁ¤ÇÏ´Â °ÍÀÔ´Ï´Ù.

    <script>
    function parentLayerEvent() {
    	alert("I am parent Layer");
    }
    function sonLayerEvent() {
    	alert("I am son Layer");
    }
    function setEvent() {
    	var DIV = document.parentLayer;
    	DIV.onmouseover = parentLayerEvent;
    	DIV.document.sonLayer.onmouseover = sonLayerEvent;
    }
    </script>
    </head>
    <body onLoad="setEvent()">
    <div id=parentLayer style="position:absolute;">parentLayer
    	<div id=sonLayer style="position:absolute;">sonLayer</div>
    </div>
    </body>
    
    ¿©±â¼­´Â ·¹À̾°Ô Á÷Á¢ À̺¥Æ®¸¦ ÁöÁ¤ÇÏÁö ¾Ê°í ÆäÀÌÁö Ãâ·ÂÈÄ bodyÀÇ onLoad À̺¥Æ®Çîµé·¯·Î ·¹À̾îÀÇ À̺¥Æ®¸¦ ÁöÁ¤Çß½À´Ï´Ù.

    ÆäÀÌÁö³»ÀÇ ¿©·¯ layer¿¡°Ô À̺¥Æ®¸¦ ÁöÁ¤ ½Ã, setEvent ÇÔ¼ö¸¦ ÀÌ·¸°Ô ÇÒ ¼öµµ ÀÖ½À´Ï´Ù.

    function allLayerEvent() { alert("EVENT"); }
    function setEvent() {
    	var DIV = document.layers;
    	for (var i=0; i < DIV.length; i++) {
    		DIV[i].onmouseover = allLayerEvent;
    	}
    }
    </head>
    <body onLoad="setEvent()">
    
    NN4¿¡¼­ position:absolute(relative); CSS Attribute¸¦ ÁöÁ¤ÇÑ ÅÃÀº ¸ðµÎ layerÀÔ´Ï´Ù.
    ÀÌÁ¦ ÆäÀÌÁö ¾ÈÀÇ ¸ðµç ÃÖ»óÀ§ÀÇ layer¿¡°Ô allLayerEvent()¸¦ ÁöÁ¤Çß½À´Ï´Ù. ¸ðµç layer¿¡°Ô ¸¶¿ì½º¸¦ °¡Á®°¡¸é "EVEVT" ¸¦ alert âÀÌ º¸¿© ÁÝ´Ï´Ù.
    var DIV = document.all.tags("div")
    IE4¿¡¼­´Â ÀÌ ÁÙ·Î ÇÏ¸é µË´Ï´Ù. allÀº ÆäÀÌÁö¿¡ ÀÖ´Â ¸ðµç ÅÃÀ» Æ÷ÇÔÇÏ´Â collectionÀÔ´Ï´Ù. html, body, script, head, pµî ¸ðµç ÅÃÀ» Æ÷ÇÔÇÕ´Ï´Ù. ÀÌÁ¦ DIV º¯¼ö´Â ÆäÀÌÁö¿¡ ÀÖ´Â ¸ðµç div ÅÃÀ» Æ÷ÇÔÇÕ´Ï´Ù. DIV[0].id´Â ÆäÀÌÁöÀÇ Ã¹ ¹øÂ°ÀÇ div ÅÃÀÇ idÀÔ´Ï´Ù.

    À§ÀÇ ÄÚµå·Î ÆäÀÌÁö¿¡ ÀÖ´Â div Åà ¸ðµÎ¿¡°Ô mouseover À̺¥Æ®Çîµé·¯¿¡ ÁöÁ¤ÇÔ¼ö·Î allLayerEvent()¸¦ ÁöÁ¤ÇÕ´Ï´Ù. div Åà ¸ðµÎ¿¡°Ô ¸¶¿ì½º¸¦ °¡Á®°¡¸é "EVENT"¸¦ alertâÀÌ º¸¿©ÁÝ´Ï´Ù.

    n4 = (document.layers) ? true : false;
    function allLayerEvent() { alert("EVENT"); }
    
    function setEvent() {
    	if (n4) var DIV = document.layers
    	else var DIV = document.all.tags("div")
    
    	for (var i=0; i < DIV.length; i++) {
    		if (DIV[i].id.indexOf("MOVE") != -1)
    			DIV[i].onmouseover = allLayerEvent;
    	}
    }
    </head>
    <body onLoad="setEvent()">
    
    ·Î ÇÏ¸é ÆäÀÌÁöÀÇ ¸ðµç div Åà layerÀÇ À̸§ Áß¿¡¼­ "MOVE"¶ó´Â ´Ü¾î°¡ µé¾î°¡ ÀÖ´Â layer¿¡°Ô allLayerEvent() ¸¦ ÁöÁ¤ÇÕ´Ï´Ù. layerÀÇ À̸§À¸·Î ÁöÁ¤¿©ºÎ¸¦ °áÁ¤ÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿©·¯ layer¿¡¼­ ƯÁ¤ layerµé¿¡°Ô À̺¥Æ® Çîµé·¯¸¦ ÁöÁ¤ÇÒ ¼ö ÀÖ½À´Ï´Ù.


    ¸¶¿ì½º ¿À¸¥ÂÊ ¹öưÀ» ´©¸£¸é ³ª¿À´Â ´ëȭâÀº NN4¿¡¼­´Â mouseDown¿¡¼­ ³ª¿À°í IE4¿¡¼­´Â mouseDown -> mouseUp ¿¡¼­ ³ª¿Â´Ù.

    TOP           Go to Event            TOP