Luigi Margarita

I'm just an analog dreamer and a digital thinker

  • Home
  • Progetti
  • Altre Attività
  • Poesie e Racconti
  • Gallery
  • Code & Tech Blog
  • Contatti
  • Download CV
image

Integrare un motore di ricerca (Google) personalizzato

							

<html>
  <head>

    <!-- chiave API -->
    <script src="https://www.google.com/jsapi?key=AIzaSyCARovw1fjKKgkLvADlaUu7QvsszfpxOVM"
        type="text/javascript"></script>
    <script type="text/javascript">
		//google.load("search", "1", {"language" : "en"});
		google.load("search", "1", {"language" : "it"});

		// Call this function when the page has been loaded
		function initialize() {
			var searchControl = new google.search.SearchControl();
			
			// site restricted web search
			var siteSearch = new google.search.WebSearch();
			//siteSearch.setUserDefinedLabel("jquery4u.com");
			siteSearch.setUserDefinedLabel("it.luigimargarita.com");
			siteSearch.setUserDefinedClassSuffix("siteSearch");
			//siteSearch.setSiteRestriction("jquery4u.com");
			siteSearch.setSiteRestriction("it.luigimargarita.com");
			searchControl.addSearcher(siteSearch);
				
			//Search API Topics
			searchControl.addSearcher(new google.search.WebSearch());
			searchControl.addSearcher(new google.search.NewsSearch());
			searchControl.addSearcher(new google.search.BlogSearch());
			searchControl.addSearcher(new google.search.ImageSearch());
			searchControl.addSearcher(new google.search.BookSearch());
			searchControl.addSearcher(new google.search.VideoSearch());
			//others
			//searchControl.addSearcher(new google.search.LocalSearch());
			//searchControl.addSearcher(new google.search.PatentSearch());
				
			// create a drawOptions object
			var drawOptions = new google.search.DrawOptions();
			// tell the searcher to draw itself in tabbed mode
			drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
			searchControl.draw(document.getElementById("searchcontrol"), drawOptions);
		}
		google.setOnLoadCallback(initialize);
    </script>
	
	<style type="text/css">
		/* the width of the controls (keep same as gsc-results for flush look) */
		#searchcontrol { width:600px; }
		.gsc-control { width:600px; }
		/* the width of the search results box; no height value = nice auto look  */
		.gsc-results { width:600px; }
		/* the width of the search input */
		.gsc-input { width:20px; }
		/* hide "powered by google" (optional) */
		.gsc-branding { display:none; }
		.gs-title a { color:orange; font-weight:bold; }
		#searchcontrol a { color:orange; }
	</style>
	
	<title>jQuery Setup Google Search API DEMO</title>
  </head>
  <body>
	<h1>Luigi Margarita Blog - Esempio di utilizzo delle Google Search API</h1>
	<p>Digita la/e parola/e da cercare!</p>
    <div id="searchcontrol"></div>
  </body>
</html>


©2014 Luigi Margarita