Don't like ads? PRO users don't see any ads ;-)

Simple onClick listener

By: html5devs on May 7th, 2012  |  syntax: HTML 5  |  size: 0.89 KB  |  hits: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>    
  4.     <title>Google Maps On Click Listener</title>
  5.     <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  6.     <script type="text/javascript">
  7.  
  8.       function initialize() {
  9.         var mapDiv = document.getElementById('map-canvas');
  10.         var map = new google.maps.Map(mapDiv, {
  11.           center: new google.maps.LatLng(37.4419, -122.1419),
  12.           zoom: 13,
  13.           mapTypeId: google.maps.MapTypeId.ROADMAP
  14.         });
  15.       }
  16.      
  17.       google.maps.event.addDomListener(window, 'load', initialize);
  18.       google.maps.event.addDomListener(window,'click',
  19.                 function(){
  20.                         window.location = 'http://www.google.com';
  21.                 }
  22.         );
  23.     </script>
  24.   </head>
  25.   <body style="font-family: Arial; border: 0 none;">
  26.     <div id="map-canvas" style="width: 500px; height: 400px"></div>
  27.   </body>
  28. </html>