Monday 8 December 2003 — This is almost 21 years old. Be careful.
I’ve added a new search feature to this site. If you visit here from a search engine, the page greets you with a welcome box, and highlights all of your search terms on the page. Try it: sample easier joy.
The work is done by some JavaScript code that parses the referrer to determine the search words, then uses DHTML to style the words on the page. The code came from Stuart Langridge via Paul Ford’s new Harper’s magazine site. I added the welcome message (though I recall seeing it done somewhere before), and also multiple color highlighting.
I don’t like the fact that the highlighting works within words rather than just on whole words, but I think it’s still a nice effect.
Comments
if (tempNodeVal.indexOf(tempWordVal) != -1) {
Changing that line to use a regular expression along the lines of '(\b|^)tempWordVal(\b|$)' might do the trick for fixing the problem with searching within a word. Of course, I haven't tried it myself... ;)
Add a comment: