Hi all
I have the following script that I want to use to rotate banners at the top of my web page ( every time the page is reloaded. I notice that this script swaps the background image in a divide, but what I want it to do is swap a GIF banner image instead of the background.
I know that I need to use document.write but am not sure where I need to make the changes to the script.
Any help would be really appreciated!!! Many thanks.
Paul
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Random Pictures</title>
<style type="text/css" title="text/css" media="all">
<!--
#header
{
position: absolute;
margin-top: 100px;
margin-left: 100px;
width: 468px;
height: 60px;
background-image: url(images/pic1.gif);
}
-->
</style>
<script type="text/javascript" language="javascript">
<!--
function swapPic()
{
if(document.getElementById)
{
var thePicture=document.getElementById("header";
var picPath="images/pic"+rnd(4)+".gif";
thePicture.style.background="url("+picPath+"";
}
}
function rnd
{
return Math.floor(Math.random() * n) + 1;
}
//-->
</script>
</head>
<body onload="swapPic()">
<div id="header"></div>
</body>
</html>
I have the following script that I want to use to rotate banners at the top of my web page ( every time the page is reloaded. I notice that this script swaps the background image in a divide, but what I want it to do is swap a GIF banner image instead of the background.
I know that I need to use document.write but am not sure where I need to make the changes to the script.
Any help would be really appreciated!!! Many thanks.
Paul
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Random Pictures</title>
<style type="text/css" title="text/css" media="all">
<!--
#header
{
position: absolute;
margin-top: 100px;
margin-left: 100px;
width: 468px;
height: 60px;
background-image: url(images/pic1.gif);
}
-->
</style>
<script type="text/javascript" language="javascript">
<!--
function swapPic()
{
if(document.getElementById)
{
var thePicture=document.getElementById("header";
var picPath="images/pic"+rnd(4)+".gif";
thePicture.style.background="url("+picPath+"";
}
}
function rnd
{
return Math.floor(Math.random() * n) + 1;
}
//-->
</script>
</head>
<body onload="swapPic()">
<div id="header"></div>
</body>
</html>