'collapse()' Example : collapse « Node Operation « JavaScript DHTML






'collapse()' 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" value="character" checked name="choose">character
<input type="radio" value="word" name="choose">word
<input type="radio" value="sentence" name="choose">sentence
</form>
<p onClick="function1();" style="cursor:hand">
Make a radio selection and then click here</p>
</body>
</html>

    
      
      








Related examples in the same category