Need help from Javascript experts.

cg1349

banned
Right now all I have is a script that changes a picture when you click on it. Here's the code:
<html>

<head>

</head>
<script language="JavaScript">
var i = 0;
function bla()
{
if (i == 0)
{
document.image.src='Yellow Spec V.jpg';
i = 1;
}
else if (i == 1)
{
document.image.src='Yellow Spec V inside.jpg';
i = 2;
}
else
{
document.image.src='Yellow Spec V top.jpg';
i = 0;
}
}
</script>


<body>
<img src='Yellow Spec V.jpg' name='image' onclick='bla()'>


</body>

</html>

So how can I modify this so that the picture changes by itself whenever you reload or refresh the page, without clicking the picture? Thanks.
 
Right now all I have is a script that changes a picture when you click on it. Here's the code:
<html>

<head>

</head>
<script language="JavaScript">
var i = 0;
function bla()
{
if (i == 0)
{
document.image.src='Yellow Spec V.jpg';
i = 1;
}
else if (i == 1)
{
document.image.src='Yellow Spec V inside.jpg';
i = 2;
}
else
{
document.image.src='Yellow Spec V top.jpg';
i = 0;
}
}
</script>


<body>
<img src='Yellow Spec V.jpg' name='image' onclick='bla()'>


</body>

</html>

So how can I modify this so that the picture changes by itself whenever you reload or refresh the page, without clicking the picture? Thanks.

you can modify the event.. instead of onclick you can write onLoad="bla()"
or you can do this on body event:
<body onLoad="bla()">
...
</body>

however the code you have posted, is all wrong because in html and javaScript you can't use ' but you must use "...
probably it'll go, but it's not right.
 
Back
Top