Hello,
I am creating a very basic glossary that has a text search function, and only want the search to apply to the words being defined (not the definitions).
Being a novice with JS, I did manage to find some code that would search the entire page (below). Whoever created it didn't credit themselves in the comments...
I am creating the glossary, so that it's a basic two column table, one for the word, one for the definition, a row for each word. Can anyone help me search just one column?
Thanks,
EB
I am creating a very basic glossary that has a text search function, and only want the search to apply to the words being defined (not the definitions).
Being a novice with JS, I did manage to find some code that would search the entire page (below). Whoever created it didn't credit themselves in the comments...
I am creating the glossary, so that it's a basic two column table, one for the word, one for the definition, a row for each word. Can anyone help me search just one column?
Thanks,
EB
Code:
// JavaScript Document
<script language="JavaScript">
<!--
var TRange=null
function findString (str) {
if (parseInt(navigator.appVersion)<4) return;
var strFound;
if (window.find) {
// CODE FOR BROWSERS THAT SUPPORT window.find
strFound=self.find(str);
if (strFound && self.getSelection && !self.getSelection().anchorNode) {
strFound=self.find(str)
}
if (!strFound) {
strFound=self.find(str,0,1)
while (self.find(str,0,1)) continue
}
}
else if (navigator.appName.indexOf("Microsoft")!=-1) {
// EXPLORER-SPECIFIC CODE
if (TRange!=null) {
TRange.collapse(false)
strFound=TRange.findText(str)
if (strFound) TRange.select()
}
if (TRange==null || strFound==0) {
TRange=self.document.body.createTextRange()
strFound=TRange.findText(str)
if (strFound) TRange.select()
}
}
else if (navigator.appName=="Opera") {
alert ("Opera browsers not supported, sorry...")
return;
}
if (!strFound) alert ("String '"+str+"' not found!")
return;
}
//-->
</script>