The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Added Search to my Blog, PLUS Highlighting

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Scott Hanselman

Posts: 1031
Nickname: glucopilot
Registered: Aug, 2003

Scott Hanselman is the Chief Architect at Corillian Corporation and the Microsoft RD for Oregon.
Added Search to my Blog, PLUS Highlighting Posted: Jan 9, 2004 8:30 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Scott Hanselman.
Original Post: Added Search to my Blog, PLUS Highlighting
Feed Title: Scott Hanselman's ComputerZen.com
Feed URL: http://radio-weblogs.com/0106747/rss.xml
Feed Description: Scott Hanselman's ComputerZen.com is a .NET/WebServices/XML Weblog. I offer details of obscurities (internals of ASP.NET, WebServices, XML, etc) and best practices from real world scenarios.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Scott Hanselman
Latest Posts From Scott Hanselman's ComputerZen.com

Advertisement

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;w
highlightWord(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.

>>

Read: Added Search to my Blog, PLUS Highlighting

Topic: The New MSN Previous Topic   Next Topic Topic: The Regulator Wiki

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use