SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast press711's Avatar
    Join Date
    Apr 2003
    Location
    gold coast
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Object expected error in IE7

    I am having troubles with my google maps javascript in IE7.


    Try : http://www.ozlittleindia.com/directo...w/16-groceries


    This works fine in firefox. But in IE7, I get an object expected error at line 458 :
    map = new GMap2(document.getElementById("map_canvas"));


    I am not sure why it seems like it is able to find the div with the id but not create the GMap2 object.


    I have moved my google maps js to the top between the head tags.


    Also, I have added window.onload = initialize to make sure that the js is being called on after the body loads.


    I tried googling it up but found no answers.


    Any ideas? Thanks.
    ---------------


  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure if this is the root cause, but since you moved the creation of the map object to within that conditional check on the div existing, it's no longer in scope for all the map.addOverlay calls.

    When I moved it back out (or declared var map outside) the JavaScript warning went away in IE8. But since I was testing on a local copy of your HTML alone, I don't know if it will render correctly on your live site.

    Try getting rid of the "if(document.getElementById("map_canvas")) {" wrapper and see if it works for you.

  3. #3
    SitePoint Enthusiast press711's Avatar
    Join Date
    Apr 2003
    Location
    gold coast
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I only added that after the error to ensure IE can find the layer.

    Anyway, I have removed it to avoid any confusion. Still get the same error.

    EDIT: Thanks for your time. I am hoping someone else is running IE7 here. Does the map show up with the placemarks in IE8?
    ---------------


  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes the map showed up in IE8 when I moved the variable. It also works in "compatibility view" which emulates IE7.

    IE8 has a JavaScript error on the exact same line with your current page.

  5. #5
    SitePoint Enthusiast press711's Avatar
    Join Date
    Apr 2003
    Location
    gold coast
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

    Problem Solved

    map = new GMap2(document.getElementById("map_canvas"));
    changed to :
    var map = new GMap2(document.getElementById("map_canvas"));
    ---------------



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •