Rotating Images Javascript

M

mikeoley

Ok what I'm trying to do should be fairly simple.

I have an image on a page that rotates with 4 other images.

All I want to do is be able to link this images to different parts of
the site when the user clicks on them. I can't figure out how to add
the "HREF" tag in there to make it work though. It's the bottom left
image that rotates. Thanks for any help or advice

<a href="http://www.eg-designdev.com/aircylinders/index3.jsp">Air
Cylinders</a>
 
M

mikeoley

upon thinking about it, I thought i'd just post the code.


<script>
<!--
var pic, alt, caption;

//add as many lines as there are pictures - remove unused
//for each picture added here there must be an entry for the alt
tag and caption below
pic = new Array;
pic[0] = "images/flash-ph6.jpg"; <----HOW DO I LINK THESE?
pic[1] = "images/flash-ph8.jpg";
pic[2] = "images/flash-ph7.jpg";
pic[3] = "images/flash-ph6.jpg";



//additions here will be used as the alternate tag for the web
browser and speech readers
alt = new Array;
alt[0] = "";
alt[1] = "";
alt[2] = "";
alt[3] = "";



//additions here will appear under the picture on the page
cap = new Array;
cap[0] = "";
cap[1] = "";
cap[2] = "";
cap[3] = "";


var now = new Date();
var seed = now.getTime() % 0xffffffff;

function rand(n) {
seed = (0x015a4e35 * seed) % 0x7fffffff;
return ( seed >> 16 ) % n;
}

var num2 = rand(4);

document.write("<img alt='" + alt[num2] + "' name='main_image'
src='" + pic[num2] + "' width='151' height='101' border='0' >");
// use the next line if we want image to link to full size version
//document.write("<a href='" + pic[num2] + "'><img alt='" + alt[num2] +
"' name='main_image' src='" + pic[num2] + "' width='151' height='101'
border='0' ></a>");
document.write("<h3>" + cap[num2]);

//-->
</script>
 
D

Dominic Myers

upon thinking about it, I thought i'd just post
the code.


<script>
<!--
var pic, alt, caption;

//add as many lines as there are pictures -
remove unused
//for each picture added here there must be
an entry for the alt
tag and caption below
pic = new Array;
pic[0] = "images/flash-ph6.jpg";
<----HOW DO I LINK THESE?
pic[1] = "images/flash-ph8.jpg";
pic[2] = "images/flash-ph7.jpg";
pic[3] = "images/flash-ph6.jpg";



//additions here will be used as the
alternate tag for the web
browser and speech readers
alt = new Array;
alt[0] = "";
alt[1] = "";
alt[2] = "";
alt[3] = "";



//additions here will appear under the picture
on the page
cap = new Array;
cap[0] = "";
cap[1] = "";
cap[2] = "";
cap[3] = "";


var now = new Date();
var seed = now.getTime() % 0xffffffff;

function rand(n) {
seed = (0x015a4e35 * seed) % 0x7fffffff;
return ( seed >> 16 ) % n;
}

var num2 = rand(4);

document.write("<img alt='" + alt[num2] + "'
name='main_image'
src='" + pic[num2] + "' width='151' height='101'
border='0' >");
// use the next line if we want image to link to
full size version
//document.write("<a href='" + pic[num2] +
"'><img alt='" + alt[num2] +
"' name='main_image' src='" + pic[num2] + "'
width='151' height='101'
border='0' ></a>");
document.write("<h3>" + cap[num2]);

//-->

</script>

I've got something similar to what it is you're
trying to do here: http://indigo.camshag.co.uk. Do
me a favour though and tell me if the banner image
is visible on your browser setup please?
Dom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top