title: Scroll to a text position in Javascript
body: <p>I have a real-time HTML editor, with a textarea on the left for code entry, and a 'preview' DIV on the right to contain the preview of the code entered. At the moment, when editing the code in the left pane, the preview just sits where it is, so often the part of the code you're editing is not in the visible area of the preview (especially when images are involved).</p>
  
  <p>My question is how do I make the preview scroll to show the part of the code that's currently being edited?</p>
  
  <p>Here is the page I have so far:
  <a href="http://www.caerphoto.com/rtedit.html" rel="nofollow noreferrer">http://www.caerphoto.com/rtedit.html</a>
  You'll notice in the source I have a (currently unused) matchPreview() function that tries to match the scroll position of the preview based on the scroll position of the textarea, but obviously if images or large text are involved the two panes no longer match.</p>