views:

116

answers:

0

I've written a COMET/Reverse Ajax table control in ASP.NET. The javascript part uses jQuery (1.3.2). It seems to be working OK, apart from when closing the browser in IE (8). In this case it throws a "Microsoft JScript runtime error: Object doesn't support this property or method". It's only when IE is closed that I get the error. Firefox and Chrome don't throw an error.

The control is a descendent of System.Web.UI.WebControls.Table.

The offending line is:

var currentCell = $("#" + gridName + " tr:nth-child(" + (rowIndex + 1) + ") td:nth-child(" + (cellIndex - rowIndex * columnCount + 1) + ")");

"gridName" is the ID of the control which is passed into the function as a parameter.

The function containing this line is called in response to a successful Ajax POST request.

The control works as expected while the page is open. I'm assuming the problem is the result of something being removed when the browser closes, so the outstanding Ajax request fails when it returns. However this is just a guess - I'm not that familiar with jQuery. I tried setting a flag in the window.unload event to prevent the offending code being called after the unload event occurs, but this didn't solve the problem.

I'm not using any Javascript libraries other than jQuery. The javascript is include as a WebResource.

The problem does not occur when I navigate to a new page - only when the browser is closed.