Table of Contents

enhanced_google_favelet

Posted 2003-01-26 @ 23:06:15

I combined my two most oft-used favelets for searching Google. Activating this one searches for the currently-selected text (if any), or prompts the user for a query:

Google [selected]

(You won't be able to test properly without dragging this to the browser's toolbar because activating the link will wipe out your current selection.)

For those interested, the underlying Javascript for this functionality is:


var s = '';
if(window.getSelection)
    s = window.getSelection();
else if(document.getSelection)
    s = document.getSelection();
if(s == '') {
    p = prompt('Search Google:','');
    if(p)
        location.href = 'http://www.google.com/search?q='+escape(p);
}
else
    window.location.href = 'http://www.google.com/search?q='+escape(s);

I've not tested on Windows browsers, but it works in IE5 & Gecko on OS X.