Forum Moderators: open
<html>
<head><title>Search Engine Test 1</title></head>
<body>
<script language="javascript" type="text/javascript"><!--
function findBoldAnchor( node ){
if( node.nodeType == 3 ){
var text = node.data ;
var searchTerm = document.searchForm.searchTerm.value ;
var offset = new Array() ;
for( i = 0; i < text.split( searchTerm ).length; i++ ){
if( i == 0 )
offset[i] = text.indexOf( searchTerm ) ;
else
offset[i] = text.indexOf( searchTerm, offset[ i - 1 ] + searchTerm.length ) ;
node.replaceData( offset[i], searchTerm.length, '<a name="' + searchTerm + '' + i + '"></a><b>' + searchTerm + '</b>' ) ;
}
}
else{
var kids = node.childNodes ;
var numkids = kids.length ;
for( var j = 0; j!= numkids; j++ ){
findBoldAnchor( kids[j] ) ;
}
}
document.getElementById( 'Output' ).innerHTML = document.getElementsByTagName( 'body' )[0].innerHTML ;
}
//-->
</script>
<p>This will be cow a paragraph of text <i>cow</i> that will be used in a search test.</p>
<table>
<tr>
<td>The search term will be cow and the object is to get those words emboldened and anchored</td>
<td>Not all fields will have the search term <i>in them</i> but will have random markup</td>
</tr>
</table>
<br/><br/>
<form action="javascript: window.navigate(window.location);" metho="post" id="searchForm" name="searchForm">
<input type="text" value="" size="20" id="searchTerm" name="searchTerm"/>
<input type="submit" value="search" onsubmit="findBoldAndAnchor( document.body ); return true;" />
</form>
<span id="Output"></span>
</body>
</html>
Try using "cow" as the search term. Thanks again!