Click to See Complete Forum and Search --> : Putting a image in a div with a onload


AnacondaAndy
03-16-2004, 09:48 AM
Hi!

I am helping out a friend that has a web page with a large image at the top. He want's it to load after the body is finished loading...so the user can read the content of the body while waiting. Is is posable to put the image in a div with a onload...so that is loads in after the body? If not is there another way?

Cheers -- Andy

TheBearMay
03-16-2004, 09:52 AM
Could always place the IMG tag where you want it to be, and then at onload set the src attribute:


...
<body onload="headImg.src='myImage.gif'">
<img id="headImg" />...

AnacondaAndy
03-16-2004, 10:00 AM
Thanks! that is a great idea...I'll play around with it...:)

AnacondaAndy
03-16-2004, 10:12 AM
It works as far as I can tell, thanks!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 TransitionalEN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Loading a image last</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

</head>

//set the src here
<body onload="topimage.src='pathOfImage.gif'">
//Place the image where you want it without the "src"
<img id="topimage" src="">

<p>body content</p>


</body>
</html>


Cheers -- Andy