I wanted to have some banners having links and some others not, not all companies that I wanted to advertise have webpages, I have changed the script in order to be able to have both options: banners with links and banners without links. If in the array of links "links" you put, instead of an URL, the character "#" then the related banner will not have an a tag. Use the following code for that:
<tr><td style="padding-left:0px; padding-top:0px; padding-bottom:0px; padding-right:0px;">
<SCRIPT LANGUAGE="JavaScript">
//create arrays for pix and links
pix=new Array("http://www.link1.com/image1.jpg","http://www.link1.com/image2.jpg","http://www.link1.com/image3.jpg") ;
links=new Array("#","http://www.link1.com/","http://www.link2.com/");
//calculate pix array length
imCt=pix.length;
function ranImage(){
//pic random array entry (image)
ran=Math.floor(Math.random()*imCt);
//get div element
var div1= document.getElementById("IMFbanner");
if (links[ran]=="#"){ //no link available
var newdiv = document.createElement('img');
newdiv.setAttribute('src', pix[0]);
newdiv.setAttribute('name', 'image');
newdiv.setAttribute('border', 0);
}
else //link available
{
var newdiv = document.createElement('a');
newdiv.setAttribute('href', links[ran]);
newdiv.setAttribute('target', '_blank');
newdiv.innerHTML="<img src='"+ pix[0] +"' name='image' border='0'>";
}
//create elements
div1.appendChild(newdiv);
document.images["image"].src=pix[ran];
}
</SCRIPT>
<span id="IMFbanner"></span>
</td>
</tr>
|