简体   繁体   中英

How to use Filter in Google Search?

I have converted a textbox search to Google Search using :

location.href = "http://images.google.com/search?q=" + val;

But, I want options of Web Search, Image Search, Local Search & News Search.

I do have :

<tr height="40">
<td width="80%" align="center" ><input id="searchText" type="text" size="100"/></td>
<td class="searchbox" width="20%" align="center"><a href="#" onclick="startSearch()">Search</a></td>
<td width="0%"></td>
</tr>

<td align="center">
<input type="radio" name="searchType" value="true"/> Web
<input type="radio" name="searchType" value="false"/> Image
<input type="radio" name="searchType" value="false"/> News
<input type="radio" name="searchType" value="false"/> Local
</td>

How do I filter this optiong using the same above link.

First of all, you really should look into using the Google Search API , which will give you a lot more power and control.

But if you need something quick and dirty, you would want to select the URL before concatenating the query. Here are the urls:

"http://www.google.com/maps?q=" + val;
"http://www.google.com/images?q=" + val;
"http://www.google.com/news?q=" + val;

etc.

So perhaps the thing to do is maintain a global variable that contains the current search URL, and then change that variable in an onclick function for each radio button.

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