Tag Archive for 'search'

Site search javascript booklet

You may have heard of a booklet or bookmarklet. These are simply snippets of javascript that are saved as bookmarks. They allow you to run a script within the context of the web page you are currently visiting. The following code allows you to perform a site specific search using Google’s search engine. Simply create a bookmark or favourite and replace the address contents with the following code:

javascript:Qr=prompt(‘Search%20site%20for’,”);if(Qr)location.href=’http://www.google.com/search?&q=site:’+encodeURIComponent(window.location.hostname)+’+’+escape(Qr)

Just copy and paste it all in one line, there are no line breaks or spaces anywhere in this script. Give the booklet an appropriate name, I call mine SiteSearch just because it makes sense to me. Now, when you are on any web page, select this booklet and you will be presented with a dialog box asking what to search for. Enter the text you are interested in, hit OK and Google will return the results for that site and that site only. This works with any javascript enabled browser including Internet Explorer, Firefox, Safari and Opera.