Help me to refresh my function automaticatlly using setTimeout .....

0 replies
I made a function that generate random pics each time when your refresh the page and function work fine.
now i wants to refresh my function automatically and i use "setTimeout" for this purpose but it didn't work

please help me to refresh my function automatically and my pics change automatically

Here is my code



<html>
<head>
<title>Untitled Document</title>
<script type="text/javascript">
function name()
{
var bannerImages = new Array( );
bannerImages[0] = "Banner1.jpg";
bannerImages[1] = "Banner2.jpg";
bannerImages[2] = "Banner3.jpg";
bannerImages[3] = "Banner4.jpg";

var randomImageIndex = Math.round( Math.random( ) * 3 );
document.write( "<img alt=\"\" src=\"imgs/" + bannerImages[randomImageIndex] + "\">" );
setTimeout('name()',500);
}
</script>

</head>

<body onload="name()">

</body>
</html>
#automaticatlly #function #refresh #settimeout

Trending Topics