Hi all,
I've written a script in javascript which finds external images, reads their dimensions, and then scale them so that they maintain their aspect ratio but fit inside a 100px by 90px box. The problem is that on the first time I visit the page the script is on (http://qwerty8.vndv.com/products/clothing.php), only one or two (of the three) images loads, if I reload it the problem goes away as long as I am using firefox, anyone know why?
I tried using safari to view the page and the problem just intensified, taking a long time to load the page, and never loading the pics.
Thanks in Advance,
Theodore
PS I've included the code below:
"function scaleimg(isrc){
var maxh = 100;
var maxw = 90;
var newImg = new Image();
newImg.src = isrc;
var height = newImg.height;
var width = newImg.width;
if(height > maxh){
var scale=maxh/height;
height *= scale;
width *= scale;
}
if(width > maxw){
scale=maxw/width;
height *= scale;
width *= scale;
}
height = Math.round(height);
width = Math.round(width);
document.write("<img src='" + isrc + "' height='" + height + "' width='" + width + "' alt='Couldn't Load Image' />");
}"
And I call it like this:
"<table width="100%" border="0"><tr>
<td width="100">
<br /><script type="text/javascript">
scaleimg("http://www.auroville.org/art&culture/dance/images/iamge1.gif");
</script>
</td><td>
<a href="/products/clothingdir/Me.php">Me</a><br /> Price:$25.55<br /><p class="description">On January 27th '02 the Aurovilians and their guests were treated to a lovely, dynamic and sprite dance performance in the Bharat Nivas Auditorium, skillfully choreographed an... <a href="/products/clothingdir/Me.php">
More</a></p></td></tr></table><br /><hr /><table width="100%" border="0"><tr>
<td width="100">
<br /><script type="text/javascript">
scaleimg("http://members.westnet.com.au/bushpoet/reunion/Iamge10.JPG");
</script>
</td><td>
<a href="/products/clothingdir/You.php">You</a><br /> Price:$99.99<br /><p class="description"><p><strong>Bob Is Cool</strong>, a free, fully standards-compliant CSS template designed by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>, released for fre... <a href="/products/clothingdir/You.php">
More</a></p></td></tr></table><br /><hr /><table width="100%" border="0"><tr>
<td width="100">
<br /><script type="text/javascript">
scaleimg("http://members.westnet.com.au/bushpoet/reunion/Iamge9.JPG");
</script>
</td><td>"
If you need more information, please contact me,
Thanks Again,
Theodore