¿¤·¹¸àÆ®¿¡ »õ·Î¿î TextRange °³Ã¼¸¦ »ý¼ºÇÑ´Ù.

Àμö/ÆĶó¸ÞÅÍ
ÆĶó¸ÞÅÍ

ÆĶó¸ÞÅÍ´Â ¾ø´Ù.

¹Ýȯ°ª

¹Ýȯ°ª oValÀº »ý¼ºµÈ TextRange °³Ã¼À̰ųª ½ÇÆÐÇϸé nullÀÌ´Ù.

Ư±â

°³Ã¼ ¼Ó¿¡¼­ ÅؽºÆ®¸¦ °ËÁ¤Çϰųª ¼öÁ¤ÇÒ ¶§ TextRange¸¦ »ç¿ëÇÑ´Ù.

Àû¿ë
°³Ã¼scriptIE

createTextRange ¸Þ¼­µå¸¦ »ç¿ëÇÏ¿© ¹®¼­ ÀüüÀÇ ³»¿ëÀ» ÅýºÅ© °³Ã¼·Î ±× HTML ÅؽºÆ®ÀÇ ±ÛÀÚ °¹¼ö¸¦ »êÃâÇÏ¿´´Ù.

<SCRIPT>
function makeTextRange(){
  var rng=document.body.createTextRange();
  if (rng!=null) alert(rng.htmlText.length);
}
</SCRIPT>
<BUTTON onclick=makeTextRange()>¿©±â¸¦ Ŭ¸¯ÇØ º¸¶ó</BUTTON>

createTextRange ¸Þ¼­µå·Î ¹®¼­ÀÇ TextRange¸¦ »ý¼ºÇÏ°í ÀνÄÀÚ·Î ÁöÁ¤ÇÑ ´ÜÃ߸¦ ã¾Æ¼­ Æ÷Ä¿½º¸¦ ÁØ´Ù
¹®¼­ÀÇ ¸ðµç ´ÜÃßµéÀÇ Ä÷º¼Ç¿¡¼­ ù¹ø° Ä÷º¼ÇÀ¸·Î TextRange¸¦ »ý¼ºÇÏ°í button ¿¤·¹¸àÆ®ÀÇ ÅýºÆ®¸¦ º¯°æ½ÃŲ´Ù.

<SCRIPT>
function changeButton(){
  var coll=document.all.tags("BUTTON");
  if (coll!=null&&coll.length>0){
    var rng1=coll[0].createTextRange();
    rng1.text='ÀÌ ´ÜÃß°¡ ¹Ù²î¾ú´Ù.';
  }
}
function selectObj(){
  var coll=document.all.tags("BUTTON");
  var txtRange=document.body.createTextRange();
  txtRange.findText(orgObj.innerText);
  txtRange.select();
}
</SCRIPT>
<BUTTON onclick=selectObj()>¿©±â¸¦ Ŭ¸¯ÇØ  ¼±ÅÃÇØ º¸¶ó.</BUTTON>
<BUTTON id=orgObj onclick=changeButton()>¿©±â¸¦ Ŭ¸¯ÇØ À§ ´ÜÃ߸¦ ¹Ù²ãº¸¶ó.</BUTTON>