Dec 8 2006

Search Engine Highlight Javascript 1.5

It has been almost a year since the last update (way too busy at the moment), but here you are — a new version of Search Engine Highlight Javascript for your websites. What is in this change:

  • More search engines are supported. Added MSN Live, Technorati and Dogpile.
  • Add the framework for search engines that don’t use query string, i.e. Technorati, Dogpile and many others.
  • Fix up an issue with Hilite.style_name_suffix = false.

It has also been tested on IE7, FF2 and Opera9. Go to the project page and download either the zipped file or the raw JS from my SVN repository.

6 Comments

  1. Ashok on 8 Dec 2006 at 8:35 pm #

    Hi,
    My name is ashok i am doing a sample project plz tell me the sample coding for search it is useful for me to finish my project

  2. xchanin on 28 Dec 2006 at 12:48 pm #

    I’m just wondering how difficult it would be to capture the search terms and place them in a text area instead of highlighting them. Any help would be appreciated.

    Thanks,
    Xchanin

  3. Zubair Masoodi on 16 Jan 2007 at 11:19 pm #

    GoodDay Sir!
    i Could not Control my excitement when i traced this article and the associated
    source code, although i have not used it as yet, but i really extend my whole hearted Appreciations to Your goodself for writing this article and helping developers all round this world
    well my task is just to fetch the keywords which the user had entered and later process them as per my own requirements , my query to yourgoodself is that how this script will be invoked fro our webpage and what i need to do in order to just copy the searched words into a javascripy array
    i shall be highly grateful to you for your valuable suggestions and rest

    Thanks once again
    Zubair

  4. Scott Yang on 17 Jan 2007 at 8:44 am #

    Zubair,

    This script attached to the window.onload event handler so it gets executed when all objects are loaded in the page. It looks at the referral of the document to determine the keyword people used to land on your page.

    To get a list of keywords, you can do (in Javascript)

    var keywords = Hilite.decodeReferrer(document.referrer);

    keywrods will just be a Javascript array of search keywords.

  5. Larry on 12 Mar 2008 at 5:31 pm #

    How would I modify this highlight code to not highlight certain words? For example, I would want “and”,”of”,”to” to highlight.

  6. Chris Ivens on 10 Apr 2012 at 11:42 pm #

    Hi there,
    I have noticed a small issue when the script is called and no highlight is present. Where there is the check on line 140:
    if (idx <= 0)

    Since the idx var is incremented just before the test, often the return value of indexOf is coming out as 0 which then means there is a false positive, event at the end of the query string.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>