Solved

image viewer

Posted on 2012-04-09
1
313 Views
Last Modified: 2012-04-10
Hello,

I have the following in an HTML table:

<td align="center" valign="middle">
                            Our Services<br />
                            <br />
                            &nbsp;<img src="art/webWorld.jpg" name="slide" width="120" height="100" alt="" onclick="location.href='forms/Vison.aspx'"
                                style="cursor: pointer;" />
                            <br />
                            <br />
                            <script type="text/javascript">
<!--
                                //variable that will increment through the images
                                var step = 1
                                function slideit() {
                                    //if browser does not support the image object, exit.
                                    if (!document.images)
                                        return
                                    document.images.slide.src = eval("image" + step + ".src")
                                    if (step < 3)
                                        step++
                                    else
                                        step = 1
                                    //call function "slideit()" every 2.5 seconds
                                    setTimeout("slideit()", 2500)
                                }
                                slideit()
//-->
                            </script>
                        </td>

It works very well. I would however like an additional feature. I would like to tie the image to a differant link everytime it cycles. Each image should have it's own seperate link. Additionaly I need to set a text field below the image with a uniques description based on the image.

Thank you
0
Comment
Question by:thenrich
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 31

Accepted Solution

by:
GwynforWeb earned 500 total points
ID: 37825881
Try this idea, it is very flexible


<table align="center">
  <tr>
    <td align="center" valign="middle">Our Services<br />
    <a href="#" id="iLink"><img name="slide" width="120" height="100" alt
    onclick="location.href='forms/Vison.aspx'" style="cursor: pointer;" /> </a><div id="iDiv"
    width="120"></div></td>
  </tr>
</table>
<script type="text/javascript">

<!--
                              ourImages = new Array ("http://www.google.com/images/logo.gif",
                                                     "http://col.stb01.s-msn.com/i/B7/EB75D45B8948F72EE451223E95A96.gif",
                                                     "https://www.google.ca/intl/en_ALL/images/logos/images_logo_lg.gif",
                                                     "http://edibleapple.com/wp-content/uploads/2009/04/apple_rainbow_logo.jpeg")

                              ourLinks = new Array ("http://www.google.com",
                                                    "http://msn.com",
                                                     "https://www.google.ca/imghp",
                                                     "http://apple.com") 
 
                              ourText = new Array ("Go to google.com",
                                                    "This for MSN, go at your own risk",
                                                     "NSFW!!!",
                                                     "Yet another apple link") 



                                //variable that will increment through the images
                                var step = 0
                                function slideit() {
                                    //if browser does not support the image object, exit.
                                    if (!document.images)
                                        return
                                    document.images.slide.src = ourImages[step]
                                    document.getElementById("iLink").href = ourLinks[step]
                                    document.getElementById("iDiv").innerHTML = ourText[step]
                                    step =(step+1)%(ourImages.length)

                                    //call function "slideit()" every 2.5 seconds
                                    setTimeout("slideit()", 2500)
                                }
                                slideit()
//-->
                            </script>

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML auto refresh to another site 4 29
Hta File displays dynamic File names 4 46
JS to redirect to prev page 8 22
A responsive image gallery using flexbox 6 21
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question