E
emma.sax
My script is as follows:
function setImageSizes() {
var staticHeight = 70;
if(!document.getElementsByTagName || !document.images) return false;
var thumbnail = document.getElementsByTagName("img");
for(var i=0; i<thumbnail.length; i++) {
if(thumbnail.className=="thumbnail_img") {
var tempImage = document.createElement("img");
tempImage.src = thumbnail.src;
//problem here
var theWidth = tempImage.width;
var theHeight = tempImage.height;
//scale new width
theWidth = Math.round((theWidth/theHeight)*staticHeight);
thumbnail.style.width=theWidth;
thumbnail.style.height=staticHeight;
}
}
}
window.onload=setImageSizes;
The problem is that Firefox (I'm using 1.5) shows tempImage width and
height as 0 - shows correctly in IE.
I can't just use getAttribute on the image in the page as they have
been set incorrectly and this code can not be changed, therefore am
trying to get the dimension of the original image on the server.
Does anyone know what I can use instead?
Thanks
M
function setImageSizes() {
var staticHeight = 70;
if(!document.getElementsByTagName || !document.images) return false;
var thumbnail = document.getElementsByTagName("img");
for(var i=0; i<thumbnail.length; i++) {
if(thumbnail.className=="thumbnail_img") {
var tempImage = document.createElement("img");
tempImage.src = thumbnail.src;
//problem here
var theWidth = tempImage.width;
var theHeight = tempImage.height;
//scale new width
theWidth = Math.round((theWidth/theHeight)*staticHeight);
thumbnail.style.width=theWidth;
thumbnail.style.height=staticHeight;
}
}
}
window.onload=setImageSizes;
The problem is that Firefox (I'm using 1.5) shows tempImage width and
height as 0 - shows correctly in IE.
I can't just use getAttribute on the image in the page as they have
been set incorrectly and this code can not be changed, therefore am
trying to get the dimension of the original image on the server.
Does anyone know what I can use instead?
Thanks
M