Forum Moderators: open
I've got a problem with the on load event keyword. It doesn't seem to want to work for me. What I'm trying to do is load an image and then after the image is fully loaded, write the word "Greetings"
But I can't get it to work with the on load keyword and I've got two examples below. The first one calls the function w() (which writes the word "Greetings") outside the body tag, and it works.
In the second one, I try to call the function w() inside the body tag with the on load keyword but for some reason it dosen't work.
Would someone show me where I'm off? I'm using MSIE version 6 if that makes a difference.
Help!
This one works.
<html>
<head><font face=times new roman size=6>
<title>Greetings</title>
<img src="Image 1.jpg" width=150 height=175>
<script language="Javascript">
function w()
{window.document.write("Greetings");}
w()
</script>
</head>
<body>
</font>
</body>
</html>
But for some reason, this one doesn't.
<html>
<head><font face=times new roman size=6>
<title>Greetings</title>
<img src="Image 1.jpg" width=150 height=175>
<script language="Javascript">
function w()
{window.document.write("Greetings");}
</script>
</head>
<body onLoad="w();">
</font>
</body>
</html>
Edit: Snap!
Going down the, you can't write to a page that's already been written path, I changed the document.write("Greetings") to alert("Greetings") and it worked fine. So I think that was the trouble.
The home page has animation on it (Images moving across the screen) and the problem was, the images needed to be fully loaded before they started to move. If not, then the images would be loading as they moved across the screen.
It was so neat. All I had to do was use onLoad to call the function that starts the animation. It was like starting a whole series of events by pushing one button. I thought that was so cool.
Thanks again for your help. It's a great group and it's good to find people whose intersts are similar to my own. Although I may have to put covers over your heads so the sun can go down.