Solved

image viewer

Posted on 2012-04-09
1
298 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now