One of Firefox's most useful features is Quick Searches, the ability to assign a keyword to a link and pass a parameter in when you launch it - like thes useful to look up "useful" in a thesaurus.


But what about shortcuts that need more than one parameter, like comparing two stock prices? Turns out that multiple parameter keyword searches in Firefox are possible, with some Javascript magic.

After the jump, find out how to compare 3 stock symbols or pit 4 words against one another with Firefox keyword searches.


Single-parameter quick searches use the %s symbol to pass information into a link. For example, a bookmark with the keyword map might be http://maps.google.com/maps?q=%s . Type map San Diego Zoo into the address bar with that bookmark set up and poof! You'll get a map of the zoo.

If you want directions from one place to another, you need multiple parameters, which you can have - with a little help from our friend Javascript. Use this link template to enable as many %s instances in your bookmark URL as you need (sorry for the horizontal scroll):

javascript:var%C2%A0s='%s'; url='###INSERT YOUR KEYWORD SEARCH URL HERE###'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='"')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i]; }}location.replace(nurl,'< BR>');

Replace ###INSERT YOUR KEYWORD SEARCH URL HERE###' with your bookmark URL that has multiple instances of the %s parameter in it.

Check out some examples of useful multi-parameter keyword bookmarks. (Note: Copy and paste each of these URLs into a new bookmark and assign a keyword to launch them from the Firefox address bar.)


Alexaholic site traffic comparison (2 sites)

javascript:var%C2%A0s='%s'; url='http://www.alexaholic.com/%s+%s'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='"')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i];}}location.replace(nurl,'<BR>');






Bookmark this and give it the keyword comparetraffic . Then, type comparetraffic lifehacker.com example.com to run it.

Google Fight (2 terms)

javascript:var%C2%A0s='%s'; url='http://googlefight.com/index.php?lang=en_GB&word1=%s&word2=%s'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='"')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i]; }}location.replace(nurl,'< BR>');






Pit two search terms against one another. Bookmark this one with the keyword fight and then try fight "Getting Things Done" Lifehacker to try it out. (Remember, multi-word values have to be enclosed in quotes.)

Google Trends (2 terms)

javascript:var%C2%A0s='%s'; url='http://www.google.com/trends?q=%s%2C%s&ctab=0&geo=all&date=all'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='"')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i]; }}location.replace(nurl,'< BR>');






Compare the usage patterns of two words using Google Trends data.

Google Maps directions (start address, destination address)

javascript:var%C2%A0s='%s'; url='http://maps.google.com/maps?saddr=%s&daddr=%s'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='%22')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i]; }}location.replace(nurl,'< BR>');






Get directions from Google Maps using a directions keyword and your starting and ending points, ie, directions "San Diego, CA" "San Francisco, CA"

Yahoo! Stock price comparison (2 stock symbols)

javascript:var%C2%A0s='%s'; url='http://finance.yahoo.com/q/bc?t=6m&s=%s&c=%s'; t=''; qc=0; chunks=url.split('%s'); for(i=0; i<s.length; i++){if(s.charAt(i)=='"')qc=qc^1; t+=((s.charAt(i)==' '&&qc)?'^':s.charAt(i)); }args=t.split(/\s/); nurl=''; for(i=0; i<chunks.length; i++){nurl+=chunks[i]; if(args[i]!=undefined)%C2%A0{args[i]=args[i].replace(/\^/g,' '); nurl+=args[i]; }}location.replace(nurl,'< BR>');


For more on quick searches, check out Adam's previously-published article, Firefox and the art of keyword bookmarking.


Multiple parameter keyword searches [MozillaZine]