SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2007
    0 Post(s)
    0 Thread(s)

    Understanding and Fixing getElementByID in IE

    Okay, I know now that there is an issue with getElementById in IE. But I'm new to javascript and DOM stuff, so I can't seem to figure out what it all means. I've been reading on this site and other programming sites and it doesn't make sense.

    I have an admin div that will contain admin links when logged in and a login form when not. So it needs to be available at all times, but I just want it to pop up when the cursor goes near the bottom of the site.

    I include the following javascript code from an external file:
    function show(id) {
           var e = document.getElementById(id);
  = 'block';
    function hide(id) {
           var e = document.getElementById(id);
  = 'none';

    And I have this at the bottom so there is a div (divAdmin) always present to be acted upon.

    <div id="divAdmin" onmouseover="show('adminBarContents')" onmouseout="hide('adminBarContents')">
        <div id="adminBarContents">
    The result is that in Firefox, as I hover over the bottom, the div "adminBarContents" is displayed within the div "adminBar" as expected. Not so in IE. There are no other elements with the same id or name, case sensitive or insensitive.

    So, I can't figure out the fix to make it work in IE. Should I add a name element? Or change the id value?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Christchurch, New Zealand
    104 Post(s)
    4 Thread(s)
    It does work on IE in a separate test, so there's something else on your page that's creating a conflict. Please provide a link or some other way for us to see the rest of the page code.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Posting Permissions

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