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

Categories

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

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

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...