First time here? Check out the site's "greatest hits" or read a post from the archives. Feel free to leave a comment or ask a question, and consider subscribing to the latest posts via RSS or e-mail. Thanks for visiting!
« Tragedy! My Watch has been delayed! | Main | REVIEWED: Microsoft Wrist.NET (MSN Direc... »

Chris Brooks mentioned today that I need to add Search to my blog.  Until I get my Google Juice up, he's totally right.  So, I added the new dasBlog 1.5 standard search (notice the search box to the left) and then took the Google Highlighting javascript code and modified it thusly:

function googleSearchHighlight() {
if (!document.createElement) return;
ref = document.referrer;
//START Added by Scott Hanselman
if
(ref.indexOf('?') == -1 || ref.indexOf('hanselman.com') != -1) //catch when I'm my OWN referrer!
{
ref = document.location.href;
if (ref.indexOf('?') == -1) return;
}
//END Added by Scott Hanselman
qs = ref.substr(ref.indexOf('?')+1);
qsa = qs.split('&');
for (i=0;iqsip = qsa[i].split('=');
if (qsip.length == 1) continue;
if (qsip[0] == 'q' || qsip[0] == 'p') { // q= for Google, p= for Yahoo
words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/);
for (w=0;whighlightWord(document.getElementsByTagName("body")[0],words[w]);
}
}
}

So this will highlight words on my site when you search from Google, Yahoo, or use the internal search.  
Give it a try!  Here's a link that searches for XmlSerializer.

Tracked by:
http://www.shahine.com/omar/PermaLink.aspx?guid=182a9e99-9582-4c65-8854-b59b5cb5... [Pingback]
http://hyperthink.net/blog/PermaLink.aspx?guid=2cdcb250-a381-484c-915d-3a2601d57... [Pingback]


Saturday, January 10, 2004 11:09:52 AM (Pacific Standard Time, UTC-08:00)
Where did you add that JavaScript code? To what page?
Saturday, January 10, 2004 8:41:28 PM (Pacific Standard Time, UTC-08:00)
The javascript gets added to EVERY page by putting it in the "Home" template.
Saturday, January 10, 2004 11:39:55 PM (Pacific Standard Time, UTC-08:00)
Cool thanks. I got this checked in now...
Monday, January 12, 2004 4:43:20 PM (Pacific Standard Time, UTC-08:00)
Is there a way to implement this using database search results?
I get my search results in the form of a dataset and bind that to a dataRepeater. Is it possible to include highlighting in my vb.net code?
Thursday, July 07, 2005 5:11:03 AM (Pacific Standard Time, UTC-08:00)
Is there a tool that you use to paste your code into your blog with the formatting.
Nishith
Comments are closed.

Contact

Sponsors

Hosting By

On this page...

Tags

Calendar

<December 2008>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Archives

Google Ads