473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
2 1983
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: howdy | last post by:
Hi all, I'm trying to rotate 5 images which load from the server. My script loads the images but when i move to the end of my array i want to cycle throught the array again so that the images will...
4
by: Ian Hubling | last post by:
I'm trying to complete a rotating banner ad within a page I have. The rotating add has four images that rotate in three-second increments. I've got the images to rotate ok - but now I want to go...
1
by: Grunt | last post by:
Hi, I have been trying to put together a rotating banner. the code works but I am having a problem with the caching of the banner images. no matter what I try the page is constantly reloading the...
31
by: Royal Denning | last post by:
I am designing a table with 2 columns and 20 rows. I want to insert small images (each with a link) and a text title in each cell of the table. On refresh of the page, I would like to have the...
14
by: mikeoley | last post by:
Why would this script below work on an html page: http://www.eg-designdev.com/aircylinders/test.htm But not a java page such as this: "http://www.eg-designdev.com/aircylinders/index3.jsp" Or...
2
by: sgMuser | last post by:
Hi, I am not a good developer of Javascript codes. Needs this help to make some modification to this famous free javascript from Anarchos. i am using this in one of my webpage. What it does is,...
11
by: bdbeames | last post by:
What I have is a is two sets of images,(Weather, optical) there is about 30 images of is each set. I have script that will rotate through the images on the main page. The user is able to view...
6
by: swethak | last post by:
Hi, I displayed the image taken from database.How to raotate that image using javascript.plz tell that how to start the logic.plz tell that some reference websites.
1
by: Jeigh | last post by:
I've been searching around quite a bit but I can't seem to find what I'm looking for. I'm after a tutorial or source code I could look at for rotating images with a fade effect. I'm looking to have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.