A quick question: how do I programatically select the text fragment of the page in FireFox? For example, there’s a paragraph of text, user clicks the button and symbols from 10-th to 15-th are selected as if user dragged a mouse in a regular way.
Share
In Firefox, you can use the Range object, as specified by W3C.
Note that you have to get the
TextNodeto set the selection, which is thefirstChildof the<p>element. Also note that this example will not work in IE, you have to use some proprietary methods. A nice introduction is on QuirksMode.