|
-
Goldfish
Changing Pictures on a website
ive been to a website where i can go one minute and see a picture on the top and go there again the next minute and have a diffrent picture and so on. how did they do that? i think what would be nice on my website.
thanks
"A"
Say what? awwww. thanks!
You are these reason Forums ROCK!!
-
Goldfish
Is it an ad rotator or just a random image? Also what technology are you wanting to use?
-
Goldfish
Example of how to do it using javascript:
Code:
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
var theImages = new Array()
theImages[0] = '1.gif'
theImages[1] = '2.gif'
theImages[2] = '3.gif'
theImages[3] = '4.gif'
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}
</script>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
showImage();
</script>
</body>
</html>
-
it can be done something like this
<script language="JavaScript" type="text/javascript"><!--
function makeArray(len)
{
for (var i = 0; i < len; i++) this[i] = null;
this.length = len;
}
// This is where the array of imagesis created.
wwwRand = new makeArray(3);
wwwRand[0] = "<img src='images/photos/image1.jpg' border='0' width='268' height='132' hspace='0' vspace='0' alt='image1'>";
wwwRand[1] = "<img src='images/photos/image2.jpg' border='0' width='268' height='132' hspace='0' vspace='0' alt='image2'>";
wwwRand[2] = "<img src='images/photos/image3.jpg' border='0' width='268' height='132' hspace='0' vspace='0' alt='image3'>";
// The random number generator.
function rand(n)
{
seed = (0x015a4e35 * seed) % 0x7fffffff;
return (seed >> 6) % n;
}
</script>
Last edited by Dan@354-Pines; 10-03-2003 at 12:49 PM.
-
-
Yup... i know its kool!!!
i think the people already sumed it up. I read bout that in my java book over the summer too. You could use it for all sorts of stuff like pics, words, quotes, and anything else you can think im pretty sure. Starcraft Legacy has a quote generator i think sorta like your picture generator!\
Have fun with your new found knowledge
-
Expensive Sushi
java is soooo complicated...
These Guys have it down to like, 10 lines of PHP..
cheers!
Mediocrity is so... uh, rated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|