Welcome visitor
* Login
* Register
It is currently May 22nd, 2019, 2:42 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  Change image when page is reloaded
PostPosted: August 14th, 2009, 5:23 am 

Posts: 31
I've seen pages that loads a different image each time i refresh the site, does anyone knows the code to make this effect?

Thank you for your help.


Top
 Profile  
 
  Re: Change image when page is reloaded
PostPosted: August 14th, 2009, 5:51 am 

Posts: 96
http://www.scriptingok.com/forum/viewtopic.php?f=12&t=595
Its JavaScript
<script type="text/javascript">     
//<![CDATA[
var i=new Array();
i[1]="file.bmp";
i[2]="file.jpg";
i[3]="file2.bmp";
i[4]="file.png";
i[5]="file.gif";
var ni=parseInt(4*Math.random()+1);
function changeImg() {document.getElementById('img').src=i[ni];}
//]]>
</script>

And this should be on your HTML document too
<body onload="changeImg();">
<img id="img" />


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron