When choosing a block of text (possibly spanning many DOM nodes), is it possible to extract the selected text and nodes using Javascript?
Imagine this HTML code:
<h1>Hello World</h1><p>Hi <b>there!</b></p>
If the user triggered a mouseDown event starting with "World ..." and then mouseUp even immediately after "there!", I hope he returns:
Text : { selectedText: "WorldHi there!" }, Nodes: [ { node: "h1", offset: 6, length: 5 }, { node: "p", offset: 0, length: 16 }, { node: "p > b", offset: 0, length: 6 } ]
I tried putting HTML in a text box, but that will only give me the selected text. I have not tried the <canvas> , but this may be another option.
If not JavaScript, is there a way that you can use the Firefox extension?
javascript firefox xhtml firefox-addon selection
Pras Dec 11 '08 at 21:56 2008-12-11 21:56
source share