title: IE's document.selection.createRange doesn't include leading or trailing blank lines
body: <p>I'm trying to extract the exact selection and cursor location from a textarea.  As usual,  what's easy in most browsers is not in IE.  </p>
  
  <p>I'm using this:</p>
  
  <pre><code>var sel=document.selection.createRange();
  var temp=sel.duplicate();
  temp.moveToElementText(textarea);
  temp.setEndPoint("EndToEnd", sel);
  selectionEnd = temp.text.length;
  selectionStart = selectionEnd - sel.text.length;
  </code></pre>
  
  <p>Which works 99% of the time.  The problem is that <code>TextRange.text</code> doesn't return leading or trailing new line characters.  So when the cursor is a couple of blank lines after a paragraph it yields a position at the end of the preceeding paragraph - rather than the actual cursor position.</p>
  
  <p>eg:</p>
  
  <pre><code>the quick brown fox|    &lt;- above code thinks the cursor is here
  
  |    &lt;- when really it's here
  </code></pre>
  
  <p>The only fix I can think of is to temporarily insert a character before and after the selection, grab the actual selection and then remove those temp characters again.  It's a hack but in a quick experiment looks like it will work.</p>
  
  <p>But first I'd like to be sure there's not an easier way.</p>