How can I highlight specific words with javascript?

 Dont Buy Textbooks. Rent 'EM Save 60-80%



I'm trying to add a single javascript string into a forum. I'm not an admin or anything but the forum allows some javascript. What I need to do is this: I have hyperlinks. When someone clicks those hyperlinks it should highlight a specific phrase on the entire site. So If the hyperlink tells the site to highlight every phrase "the" then every "the" on the site should be highlighted.

It's kinda like the highlight function from the Firefox search, except that the words that need to be highlighted are already known, and not a varying input by the user.

How can I highlight specific words with javascript?c++ tutorials



Since your examples were words, I implemented it that way. If you really want phrases, with embedded blanks, a slightly different approach is required for the parsing and replacing aspect.

<html>

<head>

<!--

No matter which you select

as "best answer" - pick one.

-->

<style type="text/css">

/* abstract class to highlight words */

.hi { background-color: yellow; }

</style>

<script type="text/javascript">

var j = 0;

function hilite(word, nRef) {

// {word}...word string to be highlighted

// (nRef}...node reference to document

// element to analyze - optional



More Related Questions and Answers ...
  • How can I replace text or a string that is in..
  • How can I safe a javascript generated page to..
  • Software: How do you fix javascript problems ..
  • How do I update <select> options from j..
  • How can I install javascript so i can chat us..
  • Is there any way to change an unlegible font ..
  • Where can i find a proxy search server that i..
  • How do you change the height and width of a p..
  • How do i go about practicing some simple Java..
  • How do people simulate the ondocumentready ev..
  • How do I know a window is already loaded in j..
  • What is the best way to write efficient Objec..
  • How do you access javascript elements in toke..
  • How can I tell my users that the page is usin..
  • How can I put javascript in an a-href attribu..
  • How do I get my Javascript links to work?
  • What phone web browsers support javascript?
  • How do you manually turn on "javascript&..
  • How can I move images with javascript using t..

  • The information post by website user , we not guarantee correctness.

    

    Dental Treatment Skin Whitening Skin Problems Skin Rashes Shoes