title: execute google image search several times in a page
body: <p>I want to write a web page which can generate images get from google search dynamically.
  The search terms for these images are different, so I need to execute google search several times, while I found it is very hard.
  I try these code modified from the source code google provided, but it could only execute the search one time:</p>
  
  <pre><code>    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
   &lt;head&gt;
    &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"/&gt;
     &lt;title&gt;Google Search API Sample&lt;/title&gt;
   &lt;script src="https://www.google.com/jsapi"&gt;&lt;/script&gt;
   &lt;script type="text/javascript"&gt;
  
    google.load('search', '1');
  
    var imageSearch;
      var keyword="sexy";
  
    function searchComplete() {
  
  
      // Check that we got results
      if (imageSearch.results &amp;&amp; imageSearch.results.length &gt; 0) {
  
        // Grab our content div, clear it.
        var contentDiv = document.getElementById('content');
        contentDiv.innerHTML = '';
  
  
        var results = imageSearch.results;
        for (var i = 0; i &lt; results.length; i++) {
          // For each result image to the screen
          var result = results[i];
          var imgContainer = document.createElement('div');
  
  
          var newImg = document.createElement('img');
  
          // There is also a result.url property which has the escaped version
          newImg.src=result.tbUrl;
  
          imgContainer.appendChild(newImg);
  
          // Put our title + image in the content
          contentDiv.appendChild(imgContainer);
        }
  
        //clear search 
        imageSearch.clearResults();
  
      }
    }
  
    function OnLoad() {
  
      // Create an Image Search instance.
      imageSearch = new google.search.ImageSearch();
  
      // Set searchComplete as the callback function when a search is 
      // complete.  The imageSearch object will have results in it.
      imageSearch.setSearchCompleteCallback(this, searchComplete, null);
  
      imageSearch.execute(keyword);
    }
  
  
    function hi(){
        keyword="usa";
        alert('hi');
         google.setOnLoadCallback(OnLoad);
        imageSearch.execute(keyword);
    }  
  
  
   google.setOnLoadCallback(OnLoad);
  
  &lt;/script&gt;
  
   &lt;/head&gt;
    &lt;body style="font-family: Arial;border: 0 none;"&gt;
     &lt;button value="hi" onClick="hi"&gt;hi&lt;/button&gt;
  &lt;div id="content"&gt;Loading...&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The program can only execute the search in OnLoad method. Actually, I tried to call google.setOnLoadCallback(OnLoad) multiple times by put it into hi() function, but it didn't work.
  Hope someone can help me to solve these problem..</p>