Monday, April 16, 2012

Cara Membuat Artikel Terkait Dengan Google Search

By. Dedi Yahya S


Pada kesempatan kali ini saya akan memberikan trik dan panduan tentang Cara Membuat Artikel Terkait Dengan Google Search.
 

Membuat Artikel Terkait Dengan Google Search :

  • Login pada Blogger
  • Masuk mode Rancangan, pada Elemen Laman
  • Pilih Tambah Gadget, kemudian Pilih HTML/JavaScript
  • Masukan kode berikut

<!-- Related Articles - Take 5 - Using JQuery & Google Search API - by Hoctro 8/2010 -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script language="Javascript" type="text/javascript">//<![CDATA[

//var website = "http://uc1n.blogspot.com";
var website = getBaseURL();
var hoctroRelated = "site:" + website + " ";
var labelArray = new Array();

function getParams() {
  $('div.post-footer-line span.post-labels a').each(function(idx, el) {
    var test = 0;
    var textLabel = $(el).html();
    for (var i = 0; i != labelArray.length; i++) {
      if (labelArray[i] == textLabel.toString()) test = 3;
    }
    if (test == 0) {
      labelArray.push(textLabel.toString());
      hoctroRelated = hoctroRelated + '"' + textLabel.toString() + '" OR ';
    }
  }); // each
}
// Callback main function
$(document).ready(function() {
  getParams() ;
}); // function

function OnLoadRelated() {
  // create a search control
  var searchControl = new google.search.SearchControl();

  // create a draw options object so that we
  // can position the search form root

  var options = new google.search.DrawOptions();
  options.setSearchFormRoot(document.getElementById("searchHoctroRelatedForm"));

  // populate with searcher
  var blogSearch = new google.search.WebSearch();
  blogSearch.setUserDefinedLabel("Related Articles");
  var options2 = new google.search.SearcherOptions();
  options2.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);

  searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
  searchControl.addSearcher(blogSearch, options2);
  searchControl.draw(document.getElementById("searchHoctroRelatedResults"), options);
  getParams();
  searchControl.execute(hoctroRelated);
}

// Copied from http://blogtutorials-01.blogspot.com/
function getBaseURL() {   var url = location.href; // entire url including querystring - also: window.location.href;
  var baseURL = url.substring(0, url.indexOf('/', 14));   if (baseURL.indexOf('http://localhost') != -1) {   // Base Url for localhost     var url = location.href; // window.location.href;     var pathname = location.pathname; // window.location.pathname;
    var index1 = url.indexOf(pathname);
    var index2 = url.indexOf("/", index1 + 1);
    var baseLocalUrl = url.substr(0, index2);     return baseLocalUrl + "/";   }   else {   // Root Url for domain name
  return baseURL + "/";   } }   // Important, this has to be called here, otherwise main var is not yet created   google.load('search', '1.0');   google.setOnLoadCallback(OnLoadRelated, true);

//]]> </script> <style>
  //#searchHoctroRelatedResults a.gs-title, a.gs-title * { color : brown; }
  //#searchHoctroRelatedResults .gs-webResult .gs-snippet { display : none; }
  //#searchHoctroRelatedResults .gs-webResult .gs-visibleUrl { display : none; }
  //#searchHoctroRelatedForm { display : none; }
</style>

<div id="searchHoctroRelatedResults">Loading...</div>
<div id="searchHoctroRelatedForm">Loading...</div>
<h6>Widget by <u><a href='http://uc1n.blogspot.com'>uc1n</a></u></h6>
  • Jika sudah, Klik Simpan
Demikian blogger tutorial mengenai Cara Membuat Artikel Terkait Dengan Google Search. 

Semoga bermanfaat dan semoga berhasil. 
Terima Kasih ^_^
Share:

0 comments:

Post a Comment

blog ariel

lazada

Blog Archive

ariel adyatna. Powered by Blogger.

Labels

Blog Archive