1

我的 onload 函数在 IE 中导致以下错误。

0x800a138f - Microsoft JScript 运行时错误:属性“initialize”的值为 null 或未定义,而不是 Function 对象。

Javascript

<head>
    <script type="text/javascript">

        function initialize() {
            // Create a style map using pre-define map_style script
            //var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"});

            "use strict";
            jsonData = locations;
            var latLng;
            var marker;
            var mapOptions = { zoom: 6, center: new google.maps.LatLng(54.40977114, -3.22742939), mapTypeId: google.maps.MapTypeId.TERRAIN };

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

            directionsDisplay.setMap(map);

            directionsDisplay.setPanel(document.getElementById("directionsPanel"));

            for (i = 0; i < jsonData.length; i += 1) {
                latLng = new google.maps.LatLng(jsonData[i].lat, jsonData[i].lng);

                // Create marker for office and put it on map
                marker = new google.maps.Marker({
                    position: latLng,
                    map: map,
                    title: jsonData[i].title
                });
            }
        }

        function attachInstructionText(marker, text) {
            "use strict";
            google.maps.event.addListener(marker, 'click', function () {
                stepDisplay.setContent(text);
                stepDisplay.open(map, marker);
            });
        }
    </script>  
    <script src="https://www.google.com/jsapi"></script>
    <script src="https://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxxxxxx&sensor=true"></script>    
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>   
</head>

<body onload="initialize()">
          ......
</body>

4

0 回答 0