Problem viewing images in netscape/firefox

Need technical advice on coding your web pages? Covers HTML, JavaScript, CSS, and some server side technologies. Also the issue of some webpages not displayed well.

Moderator: Don_HH2K

Problem viewing images in netscape/firefox

Postby sgd1977 » Sun 21 Nov, 2004 1:07 pm

Hello,
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)
sgd1977
new member
new member
 
Posts: 2
Joined: Sun 21 Nov, 2004 12:57 pm

Postby Antony » Sun 21 Nov, 2004 4:04 pm

Can you tell us your aim of this JavaScript? To dynamically create an image html?
UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.5.5 (KHTML, like Gecko) Safari/125.11
User avatar
Antony
diamond member
diamond member
 
Posts: 14510
Joined: Tue 18 Jun, 2002 11:36 pm
Location: Sydney, Australia

Yes

Postby sgd1977 » Sun 21 Nov, 2004 10:49 pm

Antony wrote:Can you tell us your aim of this JavaScript? To dynamically create an image html?


Yes, that is correct. The attributes for the html img comes from the attributes in the images tag.

Basically, it all boils down to the fact that this code will work (more or less) if I have my images stored on a slow hard drive and will not work if I have them on a fast hard drive. Just can't figure out what is going on. :? :?
UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)
sgd1977
new member
new member
 
Posts: 2
Joined: Sun 21 Nov, 2004 12:57 pm


Return to Web Design and Page Coding

Who is online

Registered users: Google [Bot]