Hi all,
After searching for the solution for my "problem" I also bumped on this forum. It seems like a forum with a lot of knowledge, so I subscribed in the hope to help and be helped
The thing is, I am working on an easy page to show my photographical work. Per category I want to make one page and show several photo's by clicking next. Everything works just fine except for this.
I use the image size parameters to read the image size and so size my table, where it's a background image of. So I have to load the image, and then read the resolution. This works fine as long as the image is loaded fast enough, but that is not always the case.
So I tried things like:
Resume, I want Javascript to wait until "newImg.complete=true"...
Is there anyone who knows how to fix it?....
After searching for the solution for my "problem" I also bumped on this forum. It seems like a forum with a lot of knowledge, so I subscribed in the hope to help and be helped
The thing is, I am working on an easy page to show my photographical work. Per category I want to make one page and show several photo's by clicking next. Everything works just fine except for this.
function LoadImg(imgSrc) {
var newImg = new Image();
newImg.src = imgSrc;
document.getElementById('PhotoWidth').style.backgroundImage = "url("+imgSrc+")";
document.getElementById("PhotoWidth").style.width = newImg.width+"px"
document.getElementById("PhotoHeight").style.height=newImg.height+"px"
};
I use the image size parameters to read the image size and so size my table, where it's a background image of. So I have to load the image, and then read the resolution. This works fine as long as the image is loaded fast enough, but that is not always the case.
So I tried things like:
and the setTimeout and setInterval "statements", but non of them seem to work.do { } while (!newImg.complete);
Resume, I want Javascript to wait until "newImg.complete=true"...
Is there anyone who knows how to fix it?....