title: Javascript Set Caret in ContentEditable Div
body: <p>I have a div tag that is contenteditable so that users can type in the div. There is a function that adds a link into the div when the user presses a button. I would like the caret to be positioned after the link so that users can continue to type. The link can be inserted many times.</p>
  
  <p>Example Code:</p>
  
  <pre><code>&lt;div id="mydiv" contenteditable="true" tabindex="-1"&gt;before &lt;a href="#"&gt;link&lt;/a&gt; after&lt;/div&gt;
  </code></pre>
  
  <p>I require this code to work in: IE, Firefox, Opera, Safari and Chrome.</p>
  
  <p>Can anyone offer any help?</p>