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 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "Null" is null or not an object error

    I'm using this code.
    Code:
    <script type='text/javascript'>
    var forum = 2
    function request() {
    if (window.XMLHttpRequest ) { return new XMLHttpRequest(); }
    else if (window.ActiveXObject) {
    try {
    return new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
    try {
    return new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) {
    return false;
    }
    }
    }
    }
    if(location.href.match(/showforum=/i) && !location.href.match("showforum=" + forum)) {
    var tr = document.getElementsByTagName('tr')
    for(k=0;k<tr.length;k++) {
    if(tr[k].innerHTML.match(/topic title/gi) && tr[k].innerHTML.match(/replies/gi)) {
    var table = tr[k].parentNode
    var tr2 = table.getElementsByTagName('tr')
    for(z=0;z<tr2.length;z++) {
    if(tr2[z].innerHTML.match(/topic title/gi)) {
    var req = request();
    var theLoc = location.href.split("?")[0]
    req.open("GET", theLoc + "?showforum=" + forum)
    req.onreadystatechange = function() {
    if(req.readyState == 4) {
    var text = req.responseText
    document.getElementsByTagName('body')[0].innerHTML += "<div id='theAnnounce' style='display: none;'>" + text + "</div>"
    var newRow = table.insertRow(z+1)
    var newCell = newRow.insertCell(-1)
    with(newCell) {
    className = "darkrow1"
    innerHTML = "&nbsp;"
    }
    }
    }
    req.send(null)
    }
    }
    }
    }
    }
    </script>
    and it keeps giving that error (see topic title) on line 397.
    Line 397 is this line.
    Code:
    var newCell = newRow.insertCell(-1)
    I can't figure out what's wrong with it. Can anyone help me?

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    what is with the -1?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New Coder
    Join Date
    Mar 2007
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That just means that the new cell will appear at the end of the row. It's the same thing as
    Code:
    insertCell()


  •  

    Posting Permissions

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