'parentTextEdit' Example : parentTextEdit « Node Operation « JavaScript DHTML






'parentTextEdit' Example

    
<html>
<body>
<script language="JavaScript">
function function1() {
   var choose, range;
   for (var i = 0; i < document.forms[0].choose.length; i++) {
      if (document.forms[0].choose[i].checked) {
         choose = document.forms[0].choose[i].value;
         break; 
      }
   }
   var x = window.event.clientX;
   var y = window.event.clientY;
   if (window.event.srcElement.parentTextEdit) {
      range = window.event.srcElement.parentTextEdit.createTextRange()
       range.collapse();
       range.moveToPoint(x, y);
       range.expand(choose);
       range.select();
     }
} 
</script>
<form>
<input type="radio" name="choose" value="character" checked>character
<input type="radio" name="choose" value="word">word
<input type="radio" name="choose" value="sentence">sentence
</form>
<p onClick="function1();"> Some text.</p>
</body>
</html>

    
      
      








Related examples in the same category