ÇÑ ¹üÀ§°¡ ´Ù¸¥ °³Ã¼ ¼Ó¿¡ Æ÷ÇԵǾî Àִ°¡¸¦ ³ªÅ¸³»´Â °ªÀ» ¹ÝȯÇÑ´Ù.
¹Ýȯ°ª bValÀº ÇÑ ¹üÀ§°¡ ´Ù¸¥ °³Ã¼¿¡ Æ÷ÇԵǾú´Â°¡¸¦ ³ªÅ¸³»´Â ºÎ¿ï°ªÀÌ´Ù.
true | oRange°¡ ¸Þ¼µå¸¦ È£ÃâÇÑ TextRange °³Ã¼¿¡ Æ÷ÇԵǾî Àְųª µ¿ÀÏÇÏ´Ù. |
false | oRange°¡ ¸Þ¼µå¸¦ È£ÃâÇÑ TextRange °³Ã¼¿¡ Æ÷ÇԵǾî ÀÖÁö ¾Ê´Ù. |
ÀÌ ±â´ÉÀº Microsoft ¾Æ´Ñ Win32 Ç÷¡Æ®Æû¿¡¼´Â ÀÛ¿ëÇÏÁö ¾ÊÀ» ¼ö ÀÖ´Ù.
°³Ã¼ | script | IE |
---|
inRange ¸Þ¼µå·Î µÎ°³ÀÇ TextRange °³Ã¼¸¦ ºñ±³ÇÑ´Ù.
<HTML> <HEAD> <SCRIPT> function doCheck1(){ var oRng1=document.body.createTextRange(); var oRng2=oRng1.duplicate(); str='oRng1.inRange(oRng2)='+oRng1.inRange(oRng2)+'<BR>oRng1.text.length='+oRng1.text.length+'<BR>'; str+='oRng2.inRange(oRng1)='+oRng2.inRange(oRng1)+'<BR>oRng2.text.length='+oRng2.text.length; showA.innerHTML=str; } </SCRIPT> </HEAD> <BODY> <BUTTON onclick="doCheck1()">Ŭ¸¯ÇÏ¿© °ËÁ¤</BUTTON> <DIV id=showA>°á°ú Ç¥½Ãâ</DIV> </BODY> </HTML>
moveToElementText ¸Þ¼µå·Î À̵¿½ÃÅ°°í inRange ¸Þ¼µå·Î °ËÁ¤ÇÑ´Ù.
<HTML> <HEAD> <SCRIPT> function doCheck2(){ var oRng1=document.body.createTextRange(); var oRng2=oRng1.duplicate(); oRng1.moveToElementText(div1); oRng2.moveToElementText(div2); str='oRng1.inRange(oRng2)='+oRng1.inRange(oRng2)+'<BR>oRng1.text='+oRng1.text; str+='<SPAN style=width:2em></SPAN>div1.innerText='+div1.innerText+'<BR>'; str+='oRng2.text='+oRng2.text; str+='<SPAN style=width:2em></SPAN>div2.innerText='+div2.innerText+'<BR>'; showB.innerHTML=str; } </SCRIPT> </HEAD> <BODY> <DIV id=div1>div1 ³»¿ë</DIV> <DIV id=div2>div2 ³»¿ë</DIV> <BUTTON onclick="doCheck2()">Ŭ¸¯ÇÏ¿© °ËÁ¤</BUTTON> <DIV id=showB>°á°ú Ç¥½Ãâ</DIV> </BODY> </HTML>
inRange ¸Þ¼µå·Î ¼·Î ´Ù¸¥ µÎ TextRange °³Ã¼¸¦ ºñ±³ÇÑ´Ù.
<HTML> <HEAD> <SCRIPT> function doCheck3(){ var oRng1=document.body.createTextRange(); var oRng3=oRng1.duplicate(); oRng3.findText('div1 ³»¿ë'); str='oRng1.inRange(oRng3)='+oRng1.inRange(oRng3)+'<BR>'; str+='oRng3.inRange(oRng1)='+oRng3.inRange(oRng1)+'<BR><BR>'; str+='oRng1.text.length='+oRng1.text.length+'<BR>'; str+='oRng3.text.length='+oRng3.text.length+' ('+oRng3.text+')'; showC.innerHTML=str; } </SCRIPT> </HEAD> <BODY> <BUTTON onclick="doCheck3()">Ŭ¸¯ÇÏ¿© °ËÁ¤</BUTTON> <DIV id=showC>°á°ú Ç¥½Ãâ</DIV> </BODY> </HTML>