Steffen: Opera verändert bildgröße nicht

Beitrag lesen

Hi zusammen,

um Bilder immmer etwa gleich groß anzuzeigen, habe ich eine kleine Funktion geschrieben, welche mir die größe anpasst. Soweit kein Problem und läuft auch 1a, außer im Opera.
Da wird die Bildgröße nicht geändert, außer wenn ich irgendwo in der Schleife ein alert habe.

Hat jemand dieses Problem schon gehabt bzw. weiß was die Ursache ist.

var maxWidth = 200;  
 var maxHeight = 170;  
 var ratio; // aspect ratio  
 var actualHeight; // actual height at width of 200  
 var actualWidth; // actual width at height of 170  
 var margin; // required margin to center  
  
 for(var i=0; i < images.length; i++) {  
  if(images[i]){  
   temp = new Image();  
   temp.src = 'images/offer/' +images[i];  
   ratio = temp.width / temp.height;  
   alert("sadhfj"); // Dann gehts, ohne nur im FF und ie  
   if(ratio > 1) { // horizontal format  
    actualHeight = maxWidth / ratio; // calc actual height at resize to maxWidth  
    margin = (maxHeight - actualHeight) / 2; // calc required margin to center  
    margin = Math.floor(margin); // round to next lower integer  
  
    document.getElementsByTagName('img')[i].style.width = maxWidth +'px'; // Set width  
  
    document.getElementsByTagName('img')[i].style.top = margin +'px'; // Set margin  
   }  
   else { // high size  
    actualWidth = maxHeight * ratio; // calc actual width at resize to maxHeight  
    margin = (maxWidth - actualWidth) / 2; // calc required margin to center  
    margin = Math.floor(margin); // round to next lower integer  
    document.getElementsByTagName('img')[i].style.height = maxHeight +'px'; // Set height  
    document.getElementsByTagName('img')[i].style.left = margin +'px'; // Set margin  
   }  
  }  
 }

Danke und Gruß
Steffen