2012-06-13 4 views
1

Internet Explorer 8에서는 예외가 발생하지만 Firefox에서는 오류가 발생합니다.Internet Explorer 8에서의 자바 스크립트 오류

Webpage error details 

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windwos NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) 
Timestamp: Wed, 13 Jun 2012 08:33:22 UTC 

Message: Object expected 
Line: 3 
Char: 1 
Code: 0 
URI: http://<ipAddress>/.../locations.js 

Message: Syntax error 
Line: 34 
Char: 11 
Code: 0 
URI: http://<ipAddress>/.../testMap1.html 

나는 다음과 같은 파일을 사용하고 있습니다 ...

testMap1.html :

<div id="map_canvas" style="width: 1200px; height: 700px;">map div foo</div> 
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> 
    <script type="text/javascript" src="/static/app/foo/locations.js"></script> 
    <!--<script type="text/javascript" src="/static/app/foo/script.js"></script>--> 
    <script type="text/javascript"> 

    var centerPoint = new google.maps.LatLng(9.449062,7.950439); 

    var parliament = new google.maps.LatLng(9.449062,7.950439); 
    var parliament1 = new google.maps.LatLng(34.449062,7.950439); 
    var marker; 
    var map; 
    var i; 

    function initialize() { 
     var mapOptions = { 
     zoom: 2, 
     mapTypeId: google.maps.MapTypeId.HYBRID, 
     center: centerPoint 
     }; 

     map = new google.maps.Map(document.getElementById("map_canvas"), 
       mapOptions); 


     for (i = 0; i < locations.length; i++) { 
      marker = new google.maps.Marker({ 
      map:map, 
      draggable: false, 
      animation: google.maps.Animation.DROP, 
      position: new google.maps.LatLng(locations[i][0], locations[i][1]), 
      }); 
      google.maps.event.addListener(marker, 'click', toggleBounce); 
     } 
    } 

// for toggleBounce, need to add ", toggleBounce" back into previous brackets. 

    function toggleBounce() { 

     if (marker.getAnimation() != null) { 
     marker.setAnimation(null); 
     } else { 
     marker.setAnimation(google.maps.Animation.BOUNCE); 
     } 

    } 
    </script> 

locations.js :

var locations = [ 
    [9.449062, 7.950439, 0], 
    [34.449062, 10.950439, 50] 
    ]; 

나는 다음과 같은 오류를보고하고

왜 이것이 효과가 없을까요? 어떤 눈먼 오류라도?

감사합니다,

매트이 줄에서 쉼표를 후행

답변

4

제거 :

position: new google.maps.LatLng(locations[i][0], locations[i][1]), 

그것은 정보 요소에서 문제가 발생합니다.

marker = new google.maps.Marker({ 
    map:map, 
    draggable: false, 
    animation: google.maps.Animation.DROP, 
    position: new google.maps.LatLng(locations[i][0], locations[i][1]) //removed comma 
}); 
+0

감사합니다. 오류가 발생했습니다. 비록 디스플레이가 없습니다. 응용 프로그램이 Javascript를 로그온으로 사용하므로 Javascript가 비활성화되지 않았습니다. – MHibbin

1

ioseb는 이미 완벽한 답변을 게시했습니다. 그러나 앞으로 이러한 오류가 발생하지 않도록 경고하는 Google 클로저 컴파일러를 사용하는 것이 좋습니다. 여기 있습니다 : http://code.google.com/p/closure-compiler/downloads/list

+0

OK 덕분에 이것 좀 봐. 나는 이것이 유용 할 수 있도록 여전히 배우고있다. – MHibbin

+0

이것은 사용 방법입니다 : "java -jar sh/compiler.jar --js file1.js file2.js filex.js". 우리는 젠킨스와 함께 이것을 사용하고 있습니다 : "java -jar sh/compiler.jar --js file1.js file2.js filex.js --warning_level QUIET>/dev/null". 이렇게하면 오류는 표시되지 않지만 종료 코드! = 0로 종료되므로 jenkins가 실패합니다. – sdepold

+0

sdepold 덕분에 일부 다운 타임이 발생하지만 현재 내 nix 컴퓨터에 액세스 할 수 없습니다. 다시 한번 감사드립니다. – MHibbin

관련 문제