I actually did something like that a few months ago: https://gist.github.com/3050333 Only the problem was a bit different, I wanted to be able to select a section of a blog post to generate a url fragment representing that selection, so, if you shared it, that section would be highlighted when entering the page, but the underlying problem is the same, example: http://gnozin.com/sobremesa/2012/07/02/buena_venta/#highl…
That's actually Really cool. Looks like you hacked it to do it positionally. What is the 9-1? I'm assuming that last bit is the range in a Dom content substring
If you have a more complex markup it becomes apparent, for example, if you selected something inside
Text
it would look like 0-1-0-0The last part is exactly what you suggested, it's just the dom content substring.
Another thing that it's not evident is that the selected text can transverse trough html elements, for example, start inside a span and end outside that span.
Sadly that blog is not under my control, maybe i should try to blow the dust off that code and make a sample page.