code_junkie

Cross browser “jump to”/“scroll” textarea

Nov 11th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. <script type="text/javascript" language="JavaScript">
  2. function Jump(line)
  3. {
  4. var ta = document.getElementById("TextArea");
  5. var lineHeight = ta.clientHeight / ta.rows;
  6. var jump = (line - 1) * lineHeight;
  7. ta.scrollTop = jump;
  8. }
  9. </script>
  10.  
  11. <textarea name="TextArea" id="TextArea"
  12. rows="40" cols="80" title="Paste text here"
  13. wrap="off"></textarea>
  14. <input type="button" onclick="Jump(98)" title="Go!" value="Jump"/>
Add Comment
Please, Sign In to add comment