title: calling javascript in infowindow google map
body: <p>I am trying to call javascript inside google map infoWindow(). I know it's a classic question. I have read a lot of similar question in stackoverflow butI  I can't find solution :( </p>
  
  <p>my code:</p>
  
  <pre><code>&lt;!DOCTYPE&gt; 
  &lt;html&gt; 
     &lt;head&gt; 
  &lt;link rel="stylesheet" type="text/css" href="http://visapi-gadgets.googlecode.com/svn/trunk/termcloud/tc.css"/&gt; 
  &lt;script type="text/javascript" src="http://visapi-gadgets.googlecode.com/svn/trunk/termcloud/tc.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt; 
     &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt; 
     &lt;title&gt;Rectangle Overlay&lt;/title&gt; 
     &lt;style type="text/css"&gt; 
     #map { 
     width:1200px; 
     height: 700px; 
     } 
     &lt;/style&gt; 
     &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;&lt;/script&gt; 
     &lt;script type="text/javascript"&gt; 
  function init() { 
  var myOptions = { 
    center: new google.maps.LatLng(38.122404, 23.862591), 
    zoom: 3, 
    mapTypeId: google.maps.MapTypeId.ROADMAP 
  }; 
  var map = new google.maps.Map(document.getElementById('map'),myOptions); 
  
  
  
    var locations = [
        ['Bondi Beach', 38.6391,23.3437],
        ["&lt;scr"+"ipt type='text/javascript'&gt;alert('test');&lt;/scr"+"ipt&gt;", 37.893, 23.936999999999998]
      ];
  
  
   var infowindow = new google.maps.InfoWindow();
  
      var marker, i;
  
      for (i = 0; i &lt; locations.length; i++) {  
        marker = new google.maps.Marker({
          position: new google.maps.LatLng(locations[i][1], locations[i][2]),
          map: map
        });
  
        google.maps.event.addListener(marker, 'click', (function(marker, i) {
          return function() {
            infowindow.setContent(locations[i][0]);
            infowindow.open(map, marker);
          }
        })(marker, i));
      }
  
  
  
   } 
   google.maps.event.addDomListener(window, 'load', init); 
   &lt;/script&gt; 
   &lt;/head&gt; 
   &lt;body&gt; 
   &lt;h1&gt;Service&lt;/h1&gt; 
  &lt;h2&gt; Map &lt;h2&gt; 
   &lt;div id="map"&gt;&lt;/div&gt;  
  
      &lt;/script&gt;
  &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; &lt;div id="chart_div" style="width: 1800px; height: 1100px;"&gt;&lt;/div&gt; &lt;/body&gt; 
   &lt;/html&gt; 
  </code></pre>
  
  <p>anyone know how to solved this issue?</p>
  
  <p>Thank you!</p>
  
  <blockquote>
    <p>EDIT:</p>
  </blockquote>
  
  <p>The answer of <a href="https://stackoverflow.com/users/1254917/jonas-grumann/" title="Jonas Grumann">Jonas Grumann</a>is correct.
  In fact the javascript that I need to run is to build a cloudword inside infowindow calling TermCloud() function . I try below code. Any idea please???</p>
  
  <pre><code> &lt;!DOCTYPE&gt; 
      &lt;html&gt; 
         &lt;head&gt; 
      &lt;link rel="stylesheet" type="text/css" href="http://visapi-gadgets.googlecode.com/svn/trunk/termcloud/tc.css"/&gt; 
      &lt;script type="text/javascript" src="http://visapi-gadgets.googlecode.com/svn/trunk/termcloud/tc.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt; 
         &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt; 
         &lt;title&gt;Rectangle Overlay&lt;/title&gt; 
         &lt;style type="text/css"&gt; 
         #map { 
         width:1200px; 
         height: 700px; 
         } 
         &lt;/style&gt; 
         &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;&lt;/script&gt; 
         &lt;script type="text/javascript"&gt; 
      function init() { 
      var myOptions = { 
        center: new google.maps.LatLng(38.122404, 23.862591), 
        zoom: 3, 
        mapTypeId: google.maps.MapTypeId.ROADMAP 
      }; 
      var map = new google.maps.Map(document.getElementById('map'),myOptions); 
  
  
  
        var locations = [
            ['Bondi Beach', 38.6391,23.3437],
            ["Hello", 37.893, 23.936999999999998]
          ];
  
  
       var infowindow = new google.maps.InfoWindow();
  
          var marker, i;
  
          for (i = 0; i &lt; locations.length; i++) {  
            marker = new google.maps.Marker({
              position: new google.maps.LatLng(locations[i][1], locations[i][2]),
              map: map
            });
  
            google.maps.event.addListener(marker, 'click', (function(marker, i) {
              return function() {
                //infowindow.setContent(locations[i][0]);
                infowindow.open(map, marker);
                var yourFunction = new YourFunction(locations[i][0])
  
              }
            })(marker, i));
          }
  
  
           var YourFunction = function(str) {
              this.init = function() {
  
            google.load("visualization", "1");
            google.setOnLoadCallback(draw);     
  
              }
              this.init();
          }
  
      function draw() {
              data = new google.visualization.DataTable();
              data.addColumn('string', 'Label');
              data.addColumn('number', 'Value');
              data.addColumn('string', 'Link');
              data.addRows(3);
              data.setValue(0, 0, 'First Term');
              data.setValue(0, 1, 10);
              data.setValue(1, 0, 'Second');
              data.setValue(1, 1, 30);
              data.setValue(1, 2, 'http://www.google.com');
              data.setValue(2, 0, 'Third');
              data.setValue(2, 1, 20);
              var outputDiv = document.getElementById('tcdiv');
              var tc = new TermCloud(outputDiv);
              tc.draw(data, null);
            }
  
  
  
       } 
  
  
  
       google.maps.event.addDomListener(window, 'load', init); 
       &lt;/script&gt; 
       &lt;/head&gt; 
       &lt;body&gt; 
       &lt;h1&gt;Service&lt;/h1&gt; 
      &lt;h2&gt; Map &lt;h2&gt; 
       &lt;div id="map"&gt;&lt;/div&gt;  
  
          &lt;/script&gt;
      &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; &lt;div id="chart_div" style="width: 1800px; height: 1100px;"&gt;&lt;/div&gt; &lt;/body&gt; 
       &lt;/html&gt; 
  </code></pre>