Google AJAX Search API
Documents: http://code.google.com/intl/zh-CN/apis/websearch/docs/
Copy Code code as follows:
<! DOCTYPE html>
<title>google AJAX Search Api</title>
<style type= "Text/css" >
#searchcontrol. Gsc-control
{
width:100%;
}
#searchcontrol. Gsc-result-cnblogs. Gs-title
{
color:red;
}
</style>
<script src= "https://www.google.com/jsapi?key=abqiaaaawut8aaij9mtqqa087ljvohtpb5b7lrdljl2cr4-
Jwbnft1mfrrrmr1royeuczcj0dts2gic8al4-va "
Type= "Text/javascript" ></script>
<script language= "Javascript" type= "Text/javascript" >
Google.load ("Search", "1");
function OnLoad () {
Search Settings
var options = new Google.search.SearcherOptions ();
Display content when search results are empty
Options.setnoresultsstring (' query result is empty! ');
Search Control instantiation
var SearchControl = new Google.search.SearchControl ();
Show 8 results per display (Value range: 1-8)
Searchcontrol.setresultsetsize (8);
Web Search
var sitecnblogs = new Google.search.WebSearch ();
Headers
Sitecnblogs.setuserdefinedlabel ("cloud-dwelling community");
Style suffix name
Sitecnblogs.setuserdefinedclasssuffix ("jb51");
Site restrictions
Sitecnblogs.setsiterestriction ("Jb51.net");
Searchcontrol.addsearcher (sitecnblogs, Options);
Local Search
var sitezjfree = new Google.search.WebSearch ();
Sitezjfree.setuserdefinedlabel ("Material search");
Sitezjfree.setsiterestriction ("Sc.jb51.net");
Searchcontrol.addsearcher (Sitezjfree, Options);
Full Web Search
Searchcontrol.addsearcher (New Google.search.WebSearch (), options);
Add Blog Search
Searchcontrol.addsearcher (New Google.search.BlogSearch (), options);
Add Video Search
Searchcontrol.addsearcher (New Google.search.VideoSearch (), options);
Add News Search
Searchcontrol.addsearcher (New Google.search.NewsSearch (), options);
Add a picture search
Searchcontrol.addsearcher (New Google.search.ImageSearch (), options);
Add Local Map Search
var localsearch = new Google.search.LocalSearch ();
"Wild Goose Pagoda" can be used in Map center marking test
Localsearch.setcenterpoint ("Xian, bell Tower");
Searchcontrol.addsearcher (Localsearch, Options);
Draw a search
var drawoptions = new Google.search.DrawOptions ();
Drawoptions.setdrawmode (Google.search.SearchControl.DRAW_MODE_TABBED);
Searchcontrol.draw (document.getElementById ("SearchControl"), drawoptions);
Execute search Query
Searchcontrol.execute ("Google API");
}
Call after frame load completes
Google.setonloadcallback (OnLoad);
</script>
<body>
<div id= "SearchControl" >
In load ...
</div>
</body>