How can I highlight specific words with javascript?
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 ...
The information post by website user , we not guarantee correctness.
Dental Treatment Skin Whitening Skin Problems Skin Rashes Shoes
