Force google image search

泄露秘密 提交于 2021-02-05 11:31:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!