Multiple parameter keyword searches

From MozillaZine Knowledge Base
Revision as of 13:20, 11 July 2004 by Koody (talk | contribs) (Typos)
Jump to navigationJump to search

The information for this was copied from a bug in bugzilla. Can't find the bug right now, so I don't know the original author for the following piece of script.


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,'
');

Simply use multiple %s signs. If one parameter contains spaces put it inside quotes.

Examples: If we would want to compare the performance of two stocks using an url similar to this: http://finance.yahoo.com/q/bc?t=6m&s=%s&c=%s

The bookamark url would be

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>');

If you chose the keyword compare you could compare Redhat's performance with SCO Groups by writing compare rhat scox

Another example given the url for a googlefight: http://www.googlefight.com/cgi-bin/compare.pl?q1=%s&q2=%s&B1=Make+a+fight%21&compare=1&langue=us

And the bookmark would be javascript:var%C2%A0s='%s';url='http://www.googlefight.com/cgi-bin/compare.pl?q1=%s&q2=%s&B1=Make+a+fight%21&compare=1&langue=us';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>');

With the keyword fight you could do a search like fight "United States" Finland