Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
532 views
in Technique[技术] by (71.8m points)

javascript - Mysterious 'object doesnt support this method'error in IE8 on google.load

i am using google search JSAPI in my local search app. Everything works fine in all the browsers except IE 8. The problem is after the specific line of code my jquery base object and google objects are drreferenced.

Its a straight forward code. I am able to reproduce the problm using this jsfiddle.

html code is

<html>
    <head>
        <title>Test Map</title>
        <script src="http://www.google.com/jsapi?" type="text/javascript"></script>

    </head>
    <body>
        <div id="map_canvas"></div>
    </body>
</html>

and JS

$(function() {
    alert(1);
    google.load('search',1);
    alert($);

    google.setOnLoadCallback(function() {       
        alert(2);
    });
});

after the line google.load('search',1) i got the following error

Error: Object doesn't support this property or method

on $ and google.

This is totally a nightmare. I am fighting with this for hours without a luck. Any IE experts here got an idea?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Change your jsFiddle to "No wrap (body)" and modify your function like so...

//$(function() {
    //alert(1);
    google.load('search',1);
    alert($);

    google.setOnLoadCallback(function() {       
        alert(2);
    });
//});

Nearly the same question asked here: Google is not defined using Google Visualization API; possibly jQuery's fault


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...