Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Website Banner Rotation

Posted on 2014-04-11
6
Medium Priority
?
104 Views
Last Modified: 2014-04-14
Hello all.

I have 4 images (banner1.png, banner2.png, banner3.png and banner4.png).

I need these images to rotate every 10 seconds, no transition effect is needed, but when the mouse overs the image, the transition effect should stop and stay on the image.

Is CSS the best way to do this? I will appreciate a sample code.

Thanks.
0
Comment
Question by:SimpleDude
[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
  • 3
  • 3
6 Comments
 
LVL 2

Expert Comment

by:GowthamNatarajan
ID: 39994289
Do you want them as slide show shown one after the other... Or all the images shown simultaneously  rotating every 10 seconds?
0
 

Author Comment

by:SimpleDude
ID: 39994336
One after other, rotating every 10 seconds.

Image 1 static for 10 seconds

then

Image 2 static for 10 seconds

etc...
0
 
LVL 2

Expert Comment

by:GowthamNatarajan
ID: 39994524
Please find the sample code below.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
   
    <script>
        ar = ["koala.jpg", "Desert.jpg", "koala.jpg", "Penguins.jpg"];
        var index = 1;
        window.setInterval(function () {
            try{
                document.getElementById("imgID").src = ar[index];
                if (index == 3) index = 0;
                else index = index + 1;
            }
            catch(e){
                alert(e.description);
            }
       
        }, 3000);
    </script>
<body>
<div id="images">
        <img id="imgID" src="Koala.jpg" />    
    </div>
</div>
</body>
</html>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:SimpleDude
ID: 39994681
Hi GowthamNatarajan

Thanks for the answer!

I tried the code, but the slideshow doesnt stop when I mouseover the banner. Anyway to make it stop?

Thanks!
0
 
LVL 2

Accepted Solution

by:
GowthamNatarajan earned 2000 total points
ID: 39998354
Try this for the 3 images...

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
   
    <script>
        function stop() {
            flag = 1;
        }
        function start() {
            flag = 0;
           
        }
        ar = ["koala.jpg", "Desert.jpg","Penguins.jpg"];
        var index = 0;
        window.setInterval(function () {
            if (flag == 0) {
                try {
                    if (index == 2) index = 0;
                    else index = index + 1;
                    document.getElementById("imgID").src = ar[index];
                }
                catch (e) {
                    alert(e.description);
                }
            }
        }, 3000);
       
       
    </script>
<body>
<div id="images" ">
        <img id="imgID" src="Koala.jpg" onmouseover="stop(this)" onmouseout="start(this)" />
    </div>
</div>
</body>
</html>
0
 

Author Closing Comment

by:SimpleDude
ID: 40000027
Thanks!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

618 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