Link to home
Start Free TrialLog in
Avatar of mikezang
mikezang

asked on

How can I select multiple tetx on web page?

I knew how to use
txt=document.body.createTextRange();
txt.findText(str)
txt.select();

to select str on web page, but i only one str can be selected using this method, I want to select all the str on page, what can I do? is it possible?
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mikezang
mikezang

ASKER

Thank you very much.
It is ok even the selection isn't used. but I want to the highlight looks like the selection, I mean the text is displayed in turn over mode, is it posiible?
No the string methods on work on the text, the background is not exposed in the string object.

Cd&
Thanks.
But I have a new question, the 'red'.fontcolor('red') is changed to '<FONT COLOR="red">red</FONT>', but I use that string in another string, something looks like as bwlow, it doesn't work!
str = "<A HREF=javascript:void onClick='document.write(\"green black <FONT COLOR="red">red</FONT>\");return false;'>COLOR</A>"

I need this one as below, what can I do?
str = "<A HREF=javascript:void onClick='document.write(\"green black <FONT COLOR=\\\"red\\\">red</FONT>\");return false;'>COLOR</A>"

I'd have to see more of the code to understand what you are doing, but if that sample is the way you are generating code, then this method is not going to work for you.  You need to re-think the design you are creating a maze of unmaintainable code.

Cd&