Problem using innerHTML
I'm trying to adapt the predictive fetch pattern in Chapter 3 to my application and find that IE7 barfs when trying to load fetched HTML code into a TD element using innerHTML. It works fine in Netscape 8. I've searched the web looking for something to tell me that this is a known bug but I can't find anything. Can anyone tell me if this is a known bug in IE7 and if there's a work around for it, if so.
My code looks like this:
HTML page code:
<table id="tblLoadArea" style="display:none" >
<tr id="tdLoadArea">
</table>
JavaScript code:
oXHR.open("get", getURLForScreen(iNextScreenToLoad) + "&dataonly=true", true);
oXHR.onreadystatechange = function () {
if (oXHR.readyState == 4) {
if (oXHR.status == 200) {
window.alert("loading screen" + iNextScreenToLoad); This alert works
var tdLoadArea = document.getElementById("tdLoadArea");
window.alert("Got tdLoadArea");This alert works
tdLoadArea.innerHTML = oXHR.responseText;
window.alert("have set tdLoadArea");IE7 crashes before this alert
var tdNewScreen = document.getElementById("tdScreen" + iNextScreenToLoad);
if (!tdNewScreen) {
window.alert("no screen found for id: tdScreen" + iNextScreenToLoad);
}
tdNewScreen.style.display = "none";
objTR = document.getElementById("screenRow");
objTR.appendChild(tdNewScreen);
tdLoadArea.innerHTML = "";
iNextScreenToLoad++;
setTimeout(loadNextScreen, iWaitBeforeLoad);
}
}
};
oXHR.send(null);
|