Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer "document.getElementById is null or not an object" IE problem

    I've posted a similar problem in "html and css" but now think it's a javascript problem so I've come here.

    Basically, I have a menu that has links to display different DIVs. Each Div has a list of thumbnails which display a corresponding large image.

    One of these Divs displays correctly and shows a large version of the thumbnail that is clicked on. However, the other 2 simply show the alternative text when the thumbnail is clicked on and no image.

    This problem is only in Internet Explorer and it also states the error "'document.getElementById(...)' is null or not an object"

    Here is the corresponding javascript.

    This is what I use to show or hide the relative DIV:
    Code:
    function showHideItems(myItem){
    
    document.getElementById(myItem).style.display = "block";
    
    switch (myItem){
    case "bear":
    document.getElementById("bear").style.display = "block";
    document.getElementById("kitsune").style.display = "none";
    document.getElementById("about").style.display = "none";
    document.getElementById("fisherman").style.display = "none";
    document.getElementById("idols").style.display = "none";
    document.getElementById("contact").style.display = "none";
    document.getElementById("homeimg").style.display = "none";
    break;
    case "kitsune":
    document.getElementById("kitsune").style.display = "block";
    document.getElementById("bear").style.display = "none";
    document.getElementById("about").style.display = "none";
    document.getElementById("fisherman").style.display = "none";
    document.getElementById("idols").style.display = "none";
    document.getElementById("contact").style.display = "none";
    document.getElementById("homeimg").style.display = "none";
    break;
    case "about":
    document.getElementById("bear").style.display = "none";
    document.getElementById("kitsune").style.display = "none";
    document.getElementById("about").style.display = "block";
    document.getElementById("fisherman").style.display = "none";
    document.getElementById("idols").style.display = "none";
    document.getElementById("contact").style.display = "none";
    document.getElementById("homeimg").style.display = "none";
    break;
    case "fisherman":
    document.getElementById("bear").style.display = "none";
    document.getElementById("kitsune").style.display = "none";
    document.getElementById("about").style.display = "none";
    document.getElementById("fisherman").style.display = "block";
    document.getElementById("idols").style.display = "none";
    document.getElementById("contact").style.display = "none";
    document.getElementById("homeimg").style.display = "none";
    break;
    case "idols":
    document.getElementById("bear").style.display = "none";
    document.getElementById("kitsune").style.display = "none";
    document.getElementById("about").style.display = "none";
    document.getElementById("fisherman").style.display = "none";
    document.getElementById("idols").style.display = "block";
    document.getElementById("contact").style.display = "none";
    document.getElementById("homeimg").style.display = "none";
    break;
    case "contact":
    document.getElementById("bear").style.display = "none";
    document.getElementById("kitsune").style.display = "none";
    document.getElementById("about").style.display = "none";
    document.getElementById("fisherman").style.display = "none";
    document.getElementById("idols").style.display = "none";
    document.getElementById("contact").style.display = "block";
    document.getElementById("homeimg").style.display = "none";
    break;
    case "homeimg":
    document.getElementById("bear").style.display = "none";
    document.getElementById("kitsune").style.display = "none";
    document.getElementById("about").style.display = "none";
    document.getElementById("fisherman").style.display = "none";
    document.getElementById("idols").style.display = "none";
    document.getElementById("contact").style.display = "none";
    document.getElementById("homeimg").style.display = "block";
    break;
    }
    
    }
    and here is the gallery javascript:
    Code:
    function LoadGallery(pictureName,imageFile,titleCaption,captionText)
    {
      document.getElementById(pictureName).src = imageFile;
      document.getElementById(titleCaption).innerHTML=captionText;
    }
    I would really appreciate any help on fixing this. Here is a link to the site too.

    Many thanks

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Where is your element with an id of BearGalleryCaption? Are you creating it dynamically in some JS function somewhere?


  •  

    LinkBacks (?)

    1. 06-20-2014, 12:20 PM

    Posting Permissions

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