Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 06-11-2009
Member
 
Join Date: Nov 2009
Posts: 518
How to have rotating images on my website?

I am not very well versed with programming languages and website development, but have got a sound understanding of html. I am planning to build a website now, that has two images on it, but only one image is shown at a time. to be exact, i want my images to be changed after every few seconds. Can anyone help me in coding for the same..???
Reply With Quote
  #2  
Old 06-11-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: How to have rotating images on my website?

Try this code, but please be careful when you insert the image path.
Code:
<html> 
<head> 
<title>Image Document</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 

<script language="javascript" type="text/javascript"> 

img = new Image() 


seconds = "5"; 

function FirstImg() 
{ 
document.myimg.src = 'http://somewhere.org/Images/Image1.gif'; //add first image address here
setTimeout("SecondImg()", seconds * 1000); 
} 
function SecondImg() 
{ 
document.myimg.src = 'http://somewhere.org/Images/Image2.jpg';//second image storage place 
setTimeout("FirstImg()", seconds * 1000); 
}
</script> 

</head> 

<body onload="firstImg();"> 
<img src="http://somewhere.org/Images/Image1.gif" name="myimg"> 
</body> 
</head>
Please revert back in case of any querries.
Reply With Quote
  #3  
Old 06-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: How to have rotating images on my website?

Code:
<body onLoad="slideShow(50000,0)">
<script language="JavaScript">

var j,d=" ",l=" ",m=" ",p=" ",q=" ",z=" ",arr= new Array()

arr[arr.length]='/firstImg.jpg';
arr[arr.length]='/secondImg.jpg';
j=parseInt(Math.random()*arr.length);
j=(isNaN(j))?0:j;
document.write("<img name='slideShow' src='"+arr[j]+"'>");
function slideShow(t,l) {
x=document.slideShow; j=l; j++; if (j==arr.length) j=0;
x.src=arr[j]; setTimeout("slideShow("+t+","+j+")",t);
}
</script>
</body>
This i think is much simple, in case you want to add images to the existing ones. All you have to do is just add a line to add the image to the array "arr". Hope this will help you..
Reply With Quote
  #4  
Old 06-11-2009
Member
 
Join Date: Nov 2009
Posts: 356
Re: How to have rotating images on my website?

Well cannot you make a GIF image with the pictures you want and the delay that is required and then upload it to the html?? I think this can ease the work a lot. Also wanna know if in programming, i want to add captions to the image i am uploading, what should i do?
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to have rotating images on my website?"
Thread Thread Starter Forum Replies Last Post
How to disable copy pasting or printing of images/texts from website? Jaques Strapp Technology & Internet 4 20-01-2012 01:31 PM
Rotating Cylinders zbathich Software Development 2 26-04-2011 04:18 AM
Rotating Controls in VB.NET GracieSingh Software Development 5 30-03-2010 12:06 AM
How to skip images or pictures to speed slow website? Yarn Technology & Internet 3 05-03-2009 06:05 PM
The Godfather Part 2: Images and official website at EA Rawko Video Games 5 02-12-2008 08:30 PM


All times are GMT +5.5. The time now is 10:06 PM.