Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- js test for "is image loaded"?


BenG - 9:29 am on Jun 28, 2002 (gmt 0)


Hello,

I've had to strip out all the images on our 'work' section as they were making the page weigh in cloes to 1MB OUCH!
I've been working on this Javascript
<script language="JavaScript">
function flip(name,src) {
if (navigator.appName == "Microsoft Internet Explorer") {
document.all.wait.style.visibility="visible";
}
else {
document.layers["wait"].visibility = "visible";
}
swapImage='images/clients/'+src
if (document.images){
document.images[name].src = swapImage;
imageTimeout = setTimeout('loadTest(name)',1000);
}
}
function loadTest(name){
if (document.images){
document.images[name].onLoad=showImage();
}
}
function showImage() {
//remove this alert when fixed....
alert("loaded");
if (navigator.appName == "Microsoft Internet Explorer") {
document.all.wait.style.visibility="hidden";
}
else {
document.layers["wait"].visibility = "hidden";
}
}
</script>
I inserted a timeout to see wether that would help, as before the onload would trigger instantly. It basically should show the 'wait' layer untill the image is loaded. Any ideas on how i can overcome this problem much appreciated.
BenG


Thread source:: http://www.webmasterworld.com/javascript/148.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com