Discussion:
Random image swap upon page load
(too old to reply)
Mark754
2004-05-07 20:54:20 UTC
Permalink
Hi, what's the best way to have certain images (slices) on an html page change
randomly each time the page is loaded or refreshed in a browser? I would create
a number of different slice images the same size as the original, in Fireworks,
and one of these images would be loaded randomly upon opening the site. Is the
image swap behavior the way to do it?

I'd appreciate it if someone would point me in the right direction. Thaks.
ZhongQiang
2004-05-08 14:36:52 UTC
Permalink
no.. definetely not. that effect is for having a image change to another upon
an event (eg, onmouseover). what you are looking for might most probably be
"http://www.dynamicdrive.com/dynamicindex14/flexislide.htm"
or"http://www.javascriptkit.com/script/cut118.shtml"

[q][i]Originally posted by: [b][b]Mark754[/b][/b][/i]
Hi, what's the best way to have certain images (slices) on an html page change
randomly each time the page is loaded or refreshed in a browser? I would create
a number of different slice images the same size as the original, in Fireworks,
and one of these images would be loaded randomly upon opening the site. Is the
image swap behavior the way to do it?

I'd appreciate it if someone would point me in the right direction. Thaks.[/q]
Fidelio
2004-05-08 16:29:48 UTC
Permalink
The script below works pretty well AND you can use any file names with
any dimensions unlike most of them.

Just add more lines like:
image[number++] = ..... as needed.

I forgot where i found this script so i could give author the proper credit.

<SCRIPT LANGUAGE="Javascript"><!--
function image() { };
image = new image();
number = 0;
// imageArray
image[number++] = "<img src='river1.jpg' border='0'>"
image[number++] = "<img src='sky2.jpg' border='0'>"
increment = Math.floor(Math.random() * number);
document.write(image[increment]);
//-->
</SCRIPT>
Post by Mark754
Hi, what's the best way to have certain images (slices) on an html page change
randomly each time the page is loaded or refreshed in a browser? I would create
a number of different slice images the same size as the original, in Fireworks,
and one of these images would be loaded randomly upon opening the site. Is the
image swap behavior the way to do it?
I'd appreciate it if someone would point me in the right direction. Thaks.
Mark754
2004-05-08 18:49:36 UTC
Permalink
Thanks guys.

I also found a couple of other extensions that do this:

[L=kaosweaver]http://www.dmxzone.com/showDetail.asp?TypeId=3&NewsId=1429[/L]

[L=yaromat]http://www.yaromat.com/dw/?t=Behavior&r=images[/L]

What I need to do is have certain slices of an image file change randomly. Can
anyone suggest which one would work best?
Mark754
2004-05-09 18:43:02 UTC
Permalink
Hi, I tried the yaromat extension and it works fine for changing the image. But
what I also need is for the hyperlink and alt text associated with the image to
change. This extension doesn't seem to be able to have this capability. Does
anyone know if any of the other solutions mentioned can do this? Thanks.
Continue reading on narkive:
Loading...