J
JE
Hi!
I am snooping around all sorts of websites and faqs, in search of a way to
pick up any selected (mouse-highlighted) text in a HTML page, and store it
in a JavaScript variable.
I have found an excellent site which actually has a great cross-platform
script for doing just this;
http://www.quirksmode.org/js/selected.html
My problem is that I also need the position of the selected text within
the document. I am finishing a Perl program for editing HTML content, and
I'd like to use such a script to submit words/paragraphs back to the
program, requesting HTML formatting tags. E.g. user selects "very
important", clicks the BOLD button. Then JS gets the text and its
position which is submitted to the Perl program, which adds <B></B> tags,
and refreshes the document.
Without the positions, I naturally get all occurrences of "very important"
in the document in boldface...
Please have a look at the two-liner script snippet in the Quirksmode
document. Is there any way to access position info without losing
cross-platform stability?
Your help would be greatly appreciated! I would love to see this idea
work.
Sincerely,
Joakim Knudsen
(e-mail address removed)
Norway
I am snooping around all sorts of websites and faqs, in search of a way to
pick up any selected (mouse-highlighted) text in a HTML page, and store it
in a JavaScript variable.
I have found an excellent site which actually has a great cross-platform
script for doing just this;
http://www.quirksmode.org/js/selected.html
My problem is that I also need the position of the selected text within
the document. I am finishing a Perl program for editing HTML content, and
I'd like to use such a script to submit words/paragraphs back to the
program, requesting HTML formatting tags. E.g. user selects "very
important", clicks the BOLD button. Then JS gets the text and its
position which is submitted to the Perl program, which adds <B></B> tags,
and refreshes the document.
Without the positions, I naturally get all occurrences of "very important"
in the document in boldface...
Please have a look at the two-liner script snippet in the Quirksmode
document. Is there any way to access position info without losing
cross-platform stability?
Your help would be greatly appreciated! I would love to see this idea
work.
Sincerely,
Joakim Knudsen
(e-mail address removed)
Norway