°³Ã¼¿¡¼ ÃÐÁ¡ÀÌ Á¦°ÅµÇ°í onblur À̺¥Æ®±â ¹ß»ýµÈ´Ù.
ÇʼöÀûÀÎ ¿ä¼ÒÀ̸ç, ÃÊÁ¡À» ÁÖ°íÀúÇÏ´Â °³Ã¼ÀÇ À̸§À̳ª °³Ã¼ ¹è¿º¯¼ö ´ëÇÑ Àμö¿¡ ÀÇÇÑ ÂüÁ¶ÀÌ´Ù.
blur() ¸Þ¼µå¿¡´Â ´Ù¸¥ ÆĶó¸ÞÅÍ´Â ¾ø´Ù.
¹Ýȯ°ªÀº ¾ø´Ù.
document.formName.inputName.blur(); document.forms[0].elements[1].blur(); windowName.blur();
blur() ¸Þ¼µå´Â ´ëºÎºÐÀÇ form °³Ã¼¿Í À©µµ¿ì(window) °³Ã¼¿¡ Àû¿ëµÇ°í, ÇØ´ç °³Ã¼µéÀº focus() ¸Þ¼µåµµ °®À¸¸ç, Javascript¿¡ ÀÇÇÏ¿© ÇØ´ç °³Ã¼¿¡ ÃÊÁ¡À» Áְųª Á¦°ÅÇÒ ¼ö ÀÖ´Ù.
°³Ã¼ À§¿¡¼ ¸¶¿ì½º¸¦ Ŭ¸¯Çϸé ÃÊÁ¡ÀÌ ÁÖ¾îÁö°í(onfocus), blur() ¸Þ¼µåÀÇ »ç¿ëÇÏ¸é ´Ù¸¥ °³Ã¼¸¦ Ŭ¸¯ÇÏ´Â °Í°ú °°Àº È¿°ú¸¦ ÁØ´Ù.
ÃÊÁ¡Àº Ç×»ó ÇÑ°³ÀÇ °³Ã¼¿¡¸¸ ÁÙ ¼ö ÀÖ°í ³ª¸ÓÁö´Â ¸ðµÎ blur() ¸Þ¼µå¸¦ »ç¿ëÇÑ °Í°ú °°Àº »óÅ°¡ µÈ´Ù.
blur() ¸Þ¼µå¸¦ »ç¿ëÇϸé ÃÊÁ¡ÀÌ Á¦°ÅµÇ°í, ÃÊÁ¡Àº ¹Ù·Î ÀÌÀü¿¡ ÃÊÁ¡À» ÁÖ¾ú´ø °³Ã¼·Î À̵¿ÇÑ´Ù.
ÀÌ ¸Þ¼µå·Î¼ ÇöÀç ÃÊÁ¡À» ¹Þ´Â ¿¤·¹¸àÆ®·Î ºÎÅÍ ÃÊÁ¡ÀÌ »ç¶óÁö´Âµ¥, ÅÇ¿¡ ÀÇÇÑ Ç×ÇØÀÇ ´ÙÀ½ ¿¤·¹¸àÆ®·Î ÃÊÁ¡ÀÌ À̵¿ÇÏÁö´Â ¾Ê´Â´Ù.
IE5¿¡¼, blur ¸Þ¼µå¿¡ ³ëÃâµÇ´Â ¿¤·¹¸àÆ®´Â tabIndex ¾ÖÆ®¸®ºäÆ®°¡ ÀÖ¾î¾ß ÇÑ´Ù.
°³Ã¼ | script | IE |
---|
ÀÌ ¸Þ¼µå´Â (¿µ¹®)DOM1(W3C Document Object Model Level 1)¿¡¼ Á¤ÀǵǾú´Ù.
¹®¼°¡ ·ÎµùµÇ¸é textAreaName ÅؽºÆ®¿¡¸®¾Æ¿¡ ÃÊÁ¡ÀÌ ¿Àµµ·Ï ÇÏ¿´´Ù. ¸¶¿ì½º¸¦ ´Ù¸¥ Çʵ忡 Ŭ¸¯Çϸç ÃÊÁ¡À» ¹Ù²ãº¸¶ó.
<FORM name="formName"> <TABLE cellpadding=3 width=100%> <TR> <TD><TEXTAREA name="textAreaName" onFocus="showArea1.innerHTML='focus';showFocus(this)" onBlur="showArea1.innerHTML='blur'">ÃÊÁ¡Àº ÇÑ°³ÀÇ °³Ã¼¿¡¸¸ ÁÙ ¼ö ÀÖ´Ù.</TEXTAREA></TD> <TD id=showArea1></TD></TR> <TR> <TD><INPUT type="text" name="textName" value="³ª¸ÓÁö´Â ¸ðµÎ blur ÀÌ´Ù" onFocus="showArea2.innerHTML='focus';showFocus(this)" onBlur="showArea2.innerHTML='blur'"></INPUT></TD> <TD id=showArea2></TD></TR> <TR> <TD><INPUT type="password" name="passwordName" value="" onFocus="showArea3.innerHTML='focus';showFocus(this)" onBlur="showArea3.innerHTML='blur'"></INPUT></TD> <TD id=showArea3></TD></TR> </TABLE> </FORM> <SCRIPT> document.onload=document.formName.textAreaName.focus(); // ¹®¼°¡ ·ÎµùµÇ¸é textAreaName¿¡ ÃÊÁ¡ÀÌ ¿Àµµ·ÏÇÑ´Ù. function showFocus(obj){ // °³Ã¼¸¦ Àμö·Î ¹Þ¾Æ ±â´ÉÇÔ¼ö¸¦ ¼öÇàÇÑ´Ù. showFocus.innerHTML='ÃÊÁ¡Àº <FONT color=blue><B>'+obj.name+'</B></FONT>¿¡ ¿Ô´Ù.'; // ÃÊÁ¡ Á¤º¸¸¦ Ãâ·ÂÇÑ´Ù. } </SCRIPT> <DIV id="showFocus" class=show style=width:400;text-align:center>ÃÊÁ¡ Á¤º¸ Ç¥½ÃÇÏ´Â °÷</DIV>