简体   繁体   中英

How can I do multi-parameter queries using Google Chrome custom search engines?

I am migrating from Firefox to Chrome and I haven't been able to copy or emulate my multiple criteria queries. In Firefox it works as a breeze using a javascript script that I have found here but after a lot of testing I think is not possible to implement in Chrome. Take a look at my modified version for converting currency:

javascript:var s='%s'; url='http://www.google.com/finance/converter?a=%s&from=%s&to=%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) {args[i]=args[i].replace(/\^/g,' '); nurl+=args[i]; }}location.replace(nurl,'< BR>');

. . Sadly this functionality was intentionally disabled, as per this bug report on Chromium (see comment #3 ).

. . If you want to replicate that functionality, you need to use the Omnibox API. Check http://developer.chrome.com/extensions/samples.html#be68e4d262d74d2457999fc402f5bf5e for an example. It is very easy to adapt the sample code for your needs.

Chrome has supported this since at least the date of your question. Here is how I do it:

javascript: (function(){
var s='%s';
url='https://www.google.com/search?hl=en&q=%s&tbo=1&tbs=qdr:%s';
query='';
urlchunks=url.split('%s');
schunks=s.split(';');
for(i=0; i<schunks.length; i++)query+=urlchunks[i]+schunks[i];
location.replace(query);
})();
  1. You can use any URL that has more than one paramenter, which takes more than one argument.
  2. To use from omnibox: search word(s);search word(s)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM