...

"Null" is null or not an object error

Garath531
07-24-2007, 06:49 PM
I'm using this 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.

var newCell = newRow.insertCell(-1)

I can't figure out what's wrong with it. Can anyone help me?

A1ien51
07-26-2007, 12:24 AM
what is with the -1?

Eric

Garath531
07-26-2007, 01:43 AM
That just means that the new cell will appear at the end of the row. It's the same thing as

insertCell()



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum