0

So, I want to search for a text (say "wikipedia") and have all the "wikipedia" in the page turn into a link that redirects to wikipedia.

Thanks!

farf
  • 1
  • 1
  • possible duplicate of [Find and replace in a webpage using javascript.](http://stackoverflow.com/questions/1155353/find-and-replace-in-a-webpage-using-javascript) – VoteyDisciple Oct 25 '10 at 20:00
  • well good luck with that, let us know if you get stuck on anything. – lincolnk Oct 25 '10 at 20:22

1 Answers1

0

I wouldnt do this by using the solution linked by VoteyDisciple, walking all elements could take a long time, and replacing innerHTML could lead you to unwanted results, while this will not only access TextNodes.

I would prefer textRanges to do this.

in MSIE: find the string with findText() and replace it using pasteHTML

in others(except opera): find the string with window.find() and surround it using surroundContents()

For opera I actually dont know a method how to find text, maybe there is an opera-specific method available.

Dr.Molle
  • 116,463
  • 16
  • 195
  • 201