Jump to content

[SOLVED] TEXTAREA - Jump To Certain Line


tarun

Recommended Posts

Try this code, based on a function from http://www.faqts.com/knowledge_base/view.phtml/aid/15728:

<html>
<head>
<script>
function setCursorPosition(oInput,oStart,oEnd) {
       if( oInput.setSelectionRange ) {
         oInput.setSelectionRange(oStart,oEnd);
       } 
       else if( oInput.createTextRange ) {
         var range = oInput.createTextRange();
          range.collapse(true);
          range.moveEnd('character',oEnd);
          range.moveStart('character',oStart);
          range.select();
       }
}
</script>
</head>
<body onload='txt.focus();setCursorPosition(txt,10,10);//move to 10th character'>
<textarea id='txt'>A bunch of text that hopefully will make this textarea end up having multiple lines in it. Have I blabbae enough yet? Yeah, I thought so...</textarea>
</body>
</html>

 

Works in FF and IE. Hope it helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.