title: window.getSelection() not working in android
body: <p>I have a webview in android and inside it i am using the <code>window.getSelection();</code> method in order to get the height of the current cursor position from top of screen. Problem is that when I have pressed enter 5 times from keyboard of android it gives the correct height but when i go back to second line and again press enter it returns the height for sixth line i.e. the new <code>&lt;br&gt;</code> added in the end rather than the height of 3 line from top. </p>
  
  <p>In short .. Suppose i have 5 line in total this function will return the height for the fifth line. but when i go to 2 line and press enter it have to return the height of third line from top but it gives me height for 6 line in android webview.</p>
  
  <p>Code is down below. I want to calculate the <code>currentLine</code> i.e. on which line does the cursor is on.</p>
  
  <pre><code>var sel = window.getSelection();
  if (sel.anchorNode != undefined) {
    if (sel.anchorNode.offsetTop != undefined)
      currentLine = Math.ceil(sel.anchorNode.offsetTop / lineHeight) + 1;
    else if (sel.anchorNode.parentNode != undefined &amp;&amp; sel.anchorNode.parentNode.offsetTop != undefined)
      currentLine = Math.ceil(sel.anchorNode.parentNode.offsetTop / lineHeight) + 1;
   }
  </code></pre>