Here is a simple VBScript that should do what you are saying, but to keep some problems from occuring the searchable text must be in a <SPAN> with the class name of "searchMe" (ie: <span class="searchMe">searchable text</span>)
anyway try playing around with it:
HTML Code:
<html>
<head>
<script type="text/vbscript">
OrigBody
= ""
Function findAndHighlight
(strFind
)
If OrigBody
= "" Then
OrigBody
= document.
body.innerHTML
End If
Set myRegExp
= New
RegExp
myRegExp.Global
= True
myRegExp.Pattern
= "(" + strFind
+ ")"
'Uncomment this to search with case sensative'
myRegExp.IgnoreCase
= True
For Each mySpan In
document.getElementsByTagName
("span")
If mySpan.className
= "searchMe" Then
mySpan.innerHTML
= myRegExp.Replace
(mySpan.innerHTML,
"<span style=" + """" + "background-color:yellow" + """" + ">$1</span>")
End If
Next
End
Function
Function resetBody
()
document.
body.innerHTML
= OrigBody
OrigBody
= ""
End
Function
</script>
</head>
<body>
<span class="searchMe">Here is some text, that is used to test code.
</span><br />
<input type="text" name="lookFor" id="lookFor" />
<input type="button" onclick="findAndHighlight(document.getElementById('lookFor').value)" value="Search" />
<input type="button" onclick="resetBody()" value="Reset" />
</body>
</html>
Btw... the reason the color coding is all funny looking is because it is color coded for javascript