I am writing an application with the following browser side javascript code:
- Code: Select all
function _PRIVATE_ACTIVESERVICE_updateArena(domDoc) {
var items=domDoc.getElementsByTagName("image"); //returns a DOMNodeList
for (var i=0;i<items.length;i++) {
var existing=document.getElementById(items[i].attributes[0].value);
switch(items[i].attributes[1].value) {
case CONST_WEIRDXSTATE_MAPELEMENT_CREATE:
case CONST_WEIRDXSTATE_MAPELEMENT_UPDATE:
var img=null;
if(existing==null) {
img=document.createElement("img");
m_arena.appendChild(img);
img.id=items[i].attributes[0].value;
img.style.position="absolute";
}
else
img=existing;
img.style.left=items[i].attributes[3].value;
img.style.top=items[i].attributes[4].value;
img.style.zIndex=items[i].attributes[5].value;
if(items[i].attributes[2].value=="true") {
img.src=items[i].attributes[6].value;
img.style.visible="visible";
}
else {
img.style.visible="hidden";
img=m_arena.removeChild(img);
img=null;
}
break;
case CONST_WEIRDXSTATE_MAPELEMENT_DELETE:
if(existing!=null) {
existing.style.visible="hidden";
existing=m_arena.removeChild(existing);
existing=null;
break;
}
}
//sgd:todo delete this comment block eventually.
/*
alert(items[i].attributes[0].value); //id
alert(items[i].attributes[1].value); //action
alert(items[i].attributes[2].value); //vis
alert(items[i].attributes[3].value); //lef
alert(items[i].attributes[4].value); //top
alert(items[i].attributes[5].value); //z
alert(items[i].attributes[6].value); //url
*/
}
}
The argument to the function is XML code returned by using the [tt]IXMLHttpRequest() API[/tt] provided by netscape. Basically, the domDoc contains a bunch of [tt]<images>[/tt] tags which I convert to [tt]<img>[/tt] tags and then the browser goes out to get them. Once, this function has completed, the calling function will make another [tt]IXMLHttpRequest()[/tt] call to get the next set of XML updates.
The problem is that this works extremely erractically in Netscape or Firefox. If my images (which are jpegs) are stored on a slow hard drive in my webserver application then these will be loaded (most of the time) in Netscape/Firefox. If I move my data to a faster hard drive or buffer the jpegs in memory of my webserver application, these will just about never render correctly.
This code ALWAYS works in IE perfectly, whether the jpegs are stored in mem, on a fast hard drive or a slower harddrive.
Please help me figure this out. I've been on it for a week and still haven't gotten to the bottom of it. It is driving me nuts!
If you need more info/clarification, please let me know.
(Post formatted by Admin)
UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)


