How to make your own time-saving search bookmarklets

TechRadar
Custom bookmarklets offer a quick and easy way to search your favourite sites

If you want to extend your browser's search capabilities then you could install a toolbar or add-on. But that'll use system resources, require regular updates, and could make your system less reliable.

A better idea is to use a bookmarklet, a piece of custom JavaScript that lives in your browser favourites and won't slow you down at all. You're clueless about JavaScript? That doesn't matter. Greg R Notess has already created some excellent search bookmarklets, so you can just borrow this Google example and tweak it to suit your needs:

javascript:q = "" + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text); if (!q) q = prompt("Search words", ""); if (q!=null) location="http://www.google.com/search?q=" + escape(q).replace(/ /g, "+"); void 0

Essentially this looks for highlighted text on the current page, then passes it to the Google search page, but the details really don't matter. All you really have to do is replace the "http://www.google.com/search?q=" part with the search URL for the site you'd like to use.

Perhaps you'd like an easy way to search the Sky Sports site, for instance. Visit www.skysports.com, enter Ronaldo in the search box and click Search. Then look at the contents of your browser address box: http://www.skysports.com/autonomy/results/1,20720,,00.html?searchtype=the+site&q=ronaldo .

Strip off our Ronaldo query and the Sky Sports search URL is "http://www.skysports.com/autonomy/results/1,20720,,00.html?searchtype=the+site&q=". Replace the Google URL in the original bookmarklet with that one and we have this:

javascript:q = "" + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text); if (!q) q = prompt("Search words", ""); if (q!=null) location="http://www.skysports.com/autonomy/results/1,20720,,00.html?searchtype=the+site&q=" + escape(q).replace(/ /g, "+"); void 0

Now create a favourite or bookmark for this page, right-click it and select Properties.

Copy and paste the above JavaScript into the Location (Firefox) or URL (IE) box, give it a name like "Search Sky Sports" and click OK.

Finally, highlight words such as "Andy Murray" on a news page you are reading, select the new bookmarklet, and you'll see the Sky Sports search results.

It's easy, and you can use the same trick with most of your favourite sites. Just find their search URL, enter it in the original Google bookmarklet, add it to your bookmarks and you're ready to go.

------------------------------------------------------------------------------------------------------

Mike Williams
Lead security reviewer

Mike is a lead security reviewer at Future, where he stress-tests VPNs, antivirus and more to find out which services are sure to keep you safe, and which are best avoided. Mike began his career as a lead software developer in the engineering world, where his creations were used by big-name companies from Rolls Royce to British Nuclear Fuels and British Aerospace. The early PC viruses caught Mike's attention, and he developed an interest in analyzing malware, and learning the low-level technical details of how Windows and network security work under the hood.