467,905 Members | 1,837 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,905 developers. It's quick & easy.

Rotating Images Javascript

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>

Oct 21 '05 #1
  • viewed: 1819
Share:
2 Replies
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>

Oct 21 '05 #2
<mi******@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
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
Oct 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by howdy | last post: by
4 posts views Thread by Ian Hubling | last post: by
31 posts views Thread by Royal Denning | last post: by
14 posts views Thread by mikeoley | last post: by
1 post views Thread by Jeigh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.