问题
I have a simple site where the top content is a navigation tab with two navigation lists: Web and Image. Under the navigation tab i have a google custom search search element/bar. The web tab is by default selected to web.
By default the google custom search will search for the web, is there any way i can force it to search for images by php or optionally javascript. So when the images tab is set in the navigation menu it will search the google images instead the web ?
回答1:
I think you can basically create your own Google Image search form. The most important thing to know is that the URL for image search looks like:
http://www.google.com/search?site=imghp&tbm=isch&q=Glee
(Where "Glee" is your search term).
Here's a simple example of how the form would be, HTML:
<h1>Google Image Search</h1>
<input type = "text" id = "srchterm"/>
<button type = "button" onclick = "reDirect();">Search!</button>
JavaScript:
function reDirect() {
window.location = 'http://www.google.com/search?site=imghp&tbm=isch&q=' + document.getElementById('srchterm').value;
}
Hope that helped you in any manner!
回答2:
have a look at this url:
http://www.google.com/search?tbm=isch&q=queen
来源:https://stackoverflow.com/questions/12012528/force-google-image-search