0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法'getElementsByTag

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'getElementsByTagName'

本文关键字:方法 getElementsByTag 属性 不支持 JavaScript 运行时错误 对象 0x800a01b6      更新时间:2023-09-26

我有一个简单的MVC应用程序,我想从谷歌地图动态显示位置。

我在这个文件中得到这个错误----

https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js中第59007列第16行未处理异常

0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法'getElementsByTagName'

视图页面包含简单的html与javaScript代码和一些javaScript文件包括----

      <!DOCTYPE html>
      <html>
      <head>
      <title></title>
      <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
      <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
      <link  href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <h1>Google Maps </h1>
    <div align="left">
    <input type="text" value="" id="searchbox" style="  width:800px;height:30px; font-size:10px; margin-top: 7px;">
    </div>
    <div align="left" id="map" style="width:800px; height: 600px; margin-top: 10px;">
   </div>
   </body>
   </html>
   <script type="text/javascript">
    $(document).ready(function () {
     var mapOptions = {
        zoom: 10,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        center: new google.maps.LatLng(41.06000, 28.98700)
             };
    var map = new google.maps.Map(document.getElementById("map"), mapOptions);
    var geocoder = new google.maps.Geocoder();
    $(function () {
        $("#searchbox").autocomplete({
            source: function (request, response) {
                if (geocoder == null) {
                    geocoder = new google.maps.Geocoder();
                }
                geocoder.geocode({ 'address': request.term }, function (results, status) {
                    if (status == google.maps.GeocoderStatus.OK) {
                        var searchLoc = results[0].geometry.location;
                        var lat = results[0].geometry.location.lat();
                        var lng = results[0].geometry.location.lng();
                        var latlng = new google.maps.LatLng(lat, lng);
                        var bounds = results[0].geometry.bounds;
                        geocoder.geocode({ 'latLng': latlng }, function (results1, status1) {
                            if (status1 == google.maps.GeocoderStatus.OK) {
                                if (results1[1]) {
                                    response($.map(results1, function (loc) {
                                        return {
                                            label: loc.formatted_address,
                                            value: loc.formatted_address,
                                            bounds: loc.geometry.bounds
                                        }
                                    }));
                                }
                            }
                        });
                    }
                });
            },
            select: function (event, ui) {
                var pos = ui.item.position;
                var lct = ui.item.locType;
                var bounds = ui.item.bounds;
                if (bounds) {
                    map.fitBounds(bounds);
                }
            }
        });
    });
});

想回答我的问题 ...................我认为那些旧的javaScript库文件与新版本的IE9不兼容。所以,我只是将引用的js库文件从这个更改为最新的page....developers.google.com/speed/libraries,现在一切正常....

您可以在项目中包含jquery migrate js文件来解决这个问题。http://code.jquery.com/jquery-migrate-1.2.1.js

我希望我能把这个作为评论,但是我没有足够的代表…

0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法'Show'

上面的错误让我想到了这个问题,当我没有找到答案时,我又看了一遍,答案要简单得多——我把"show"误打成了"show"。

$("#成员").closest (.form-group),告诉();

我把它改回小写的's'- .show() -我希望这能提醒别人。

添加了最新版本的jquery并解决了问题…

像…"jquery-1.10.2.js".div . .