IE兼容模式下未定义JSON对象

时间:2013-09-26 08:55:45

标签: javascript internet-explorer

<script type="text/javascript">
    function initialize() {
        var markers = JSON.parse('[{"title":"Chennai","lat":"12.897400","lng":"80.288000","Description":"welcome to chennai"},{"title":"Hyderabad","lat":"17.266700","lng":"78.530200","Description":"welcome to hyderabad"},{"title":"Banglore","lat":"12.897400","lng":"77.519500","Description":"welcome to Banglore"},{"title":"vishkapatnam","lat":"17.518300","lng":"83.320300","Description":"welcome to Vishkapatnam"}]');
        var mapOptions = {
            center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
            zoom: 5,
            mapTypeId: google.maps.MapTypeId.ROADMAP

        };

我发现JSON找不到微软?那我该怎么办?

2 个答案:

答案 0 :(得分:2)

检查您是否处于兼容模式。 您可以通过元标记

确保IE8不在IE7模式下渲染
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />

或最好使用doctype

<!DOCTYPE html>

答案 1 :(得分:0)

代码前的某个地方:

window.JSON || 
    document.write('<script src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.2.4/json3.min.js"><\/script>');