getting the selected html element offset related to the html source code with js
<p>Can I get the offset of a selected html element in the html source code?</p>

<p>for example:</p>

<p><code>&lt;html&gt;
      &lt;body&gt;
       &lt;a href="http://google.com"&gt;google&lt;/a&gt;
      &lt;/body&gt;
     &lt;html&gt;</code></p>

<p>if the user would select the google text, I would want to get 40 as this is the offset from the start of the source.</p>

<p>I tried with Range object but couldn't find something helpful with this one. </p>

<p>Thanks!</p>
