document.getElementById(...)' is null or not an object in IE

Discussion in 'JavaScript' started by seolab, Sep 12, 2009.

  1. #1
    This is the code, maybe somebody can tell me what to do?

    } else
    setTimeout('goHttp(' + step + ')', 1000);
    } else {
    if(response.substr(0,16).indexOf(':') > -1) {
    var func = response.substr(0,response.indexOf(':'));
    if(func == 'whois') {
    if(response == 'whois:DNE')
    document.getElementById('TSRwtoggle').innerHTML = 'The domain does not exist in whois records.';
    else {
    document.getElementById('TSRwtoggle').innerHTML = '';
    document.getElementById('TSRwtogglelink').style.display = 'inline';
    }
    }
    document.getElementById('TSR' + func).innerHTML = response.substring(response.indexOf(':') + 1);
    }
    comp[step] = 1;
    comps++;
    }
    if(comps == Steps) {
    active = false;
    url = '';
    abort = false;
    document.forms['TSRform'].elements['submit'].value = 'Lookup';
    }
    slideMeDown();
     
    seolab, Sep 12, 2009 IP
  2. ohteddy

    ohteddy Member

    Messages:
    128
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #2
    Make sure that func is what you think it is. I'm assuming the line that is failing is:

    document.getElementById('TSR' + func).innerHTML = response.substring(response.indexOf(':') + 1);

    Otherwise make sure the other id's exist. You may want to create a js function called $id or something that first
    ensures that the id exists and alerts if it doesn't, this will help weed out typos in your html.
     
    ohteddy, Sep 13, 2009 IP
  3. Dregond Rahl

    Dregond Rahl Peon

    Messages:
    16
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Can you show the full code? and use the code tags too =] ?
     
    Dregond Rahl, Sep 14, 2009 IP