2012-02-07 3 views
0

이 코드는 Chrome과 IE 9에서 잘 작동합니다. 그러나 IE 8에서는 작동하지 않습니다.bind (this)

잘못된 행이 여기에 있습니다. 나는 그것이 묶인 것 같아.

google.maps.event.addListener(this.map, "click", (this.leftClick).bind(this)); 

이 문제가 발생한 사람이 있습니까? 누군가가 이것을 가지고있는지는 확실하지 않습니다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head> 
<style> 
    html, body, #map 
    { 
     margin: 0; 
     padding: 0; 
     height: 100%; 
     width: 100%; 
    } 
</style> 

<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.js"></script> 
<script src="http://maps.googleapis.com/maps/api/js?libraries=geometry,drawing&sensor=true" type="text/javascript"></script> 
<script language="javascript"> 

    var MyPage = function() { 
     this.map = null; //google map 
    }; 

    MyPage.prototype.initialize = function() { 
     this.map = new google.maps.Map(document.getElementById("map"), 
     { 
      zoom: 8, 
      center: new google.maps.LatLng(30, -97), 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     }); 

     google.maps.event.addListener(this.map, "click", (this.leftClick).bind(this)); 
    } 

    MyPage.prototype.leftClick = function (event) { 
     alert('hi'); 
    } 

    $(window).load(function(){ 
     var my = new MyPage(); 
     my.initialize(); 
    }); 

</script> 
</head> 
<body> 
<div id="map"></div> 
</body> 
</html> 

답변