Google AJAX search API
Document: http://code.google.com/intl/zh-CN/apis/websearch/docs/
Copy codeThe Code is as follows: <! DOCTYPE html>
<Html>
<Head>
<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 ();
// The content is displayed when the search result is empty.
Options. setNoResultsString ('query result is blank! ');
// Search control instantiation
Var searchControl = new google. search. SearchControl ();
// Display 8 search results each time (value range: 1-8)
SearchControl. setResultSetSize (8 );
// Webpage Search
Var siteCnblogs = new google. search. WebSearch ();
// Header
SiteCnblogs. setUserDefinedLabel (" ");
// Style suffix
SiteCnblogs. setUserDefinedClassSuffix ("jb51 ");
// Site restrictions
SiteCnblogs. setSiteRestriction ("jb51.net ");
SearchControl. addSearcher (siteCnblogs, options );
// Partial search
Var siteZjfree = new google. search. WebSearch ();
SiteZjfree. setUserDefinedLabel ("material search ");
SiteZjfree. setSiteRestriction ("SC .jb51.net ");
SearchControl. addSearcher (siteZjfree, options );
// Search all over the network
SearchControl. addSearcher (new google. search. WebSearch (), options );
// Add a blog search
SearchControl. addSearcher (new google. search. BlogSearch (), options );
// Add a Video Search
SearchControl. addSearcher (new google. search. VideoSearch (), options );
// Add news search
SearchControl. addSearcher (new google. search. NewsSearch (), options );
// Add Image Search
SearchControl. addSearcher (new google. search. ImageSearch (), options );
// Add a local map search
Var localSearch = new google. search. LocalSearch ();
// You can use the "Big Wild Goose Pagoda" When marking the map center"
LocalSearch. setCenterPoint ("Xi'an, Bell Tower ");
SearchControl. addSearcher (localSearch, options );
// Draw 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.exe cute ("google api ");
}
// Call after the framework is loaded
Google. setOnLoadCallback (OnLoad );
</Script>
</Head>
<Body>
<Div id = "searchcontrol">
Loading...
</Div>
</Body>
</Html>