473,396 Members | 2,102 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,396 software developers and data experts.

Slideshow stop on mouseover start on mouseout

Hi people,

I am quite new to JS-scripting and I have a question.
Finally I found a "good" slideshow which works in IE, Chrome, FF with prototype.

The only thing is that I would like the slideshow to stop when the mouse is over the slideshow and start again when the pointer leaves the pics.

Thanks alot in advance!

Already found something, but don't know how to implement it:

------
myTimer = setTimeout(.............)

onmouseover = clearTimeout(myTimer)
onmouseout = fadeInOut();

-------
script:
-------

Expand|Select|Wrap|Line Numbers
  1. var delay = 4000;
  2. var start_frame = 0;
  3.  
  4. function init() {
  5.     var lis = $('slide-images').getElementsByTagName('li');
  6.  
  7.     for( i=0; i < lis.length; i++){
  8.         if(i!=0){
  9.             lis[i].style.display = 'none';
  10.         }
  11.     }
  12.     end_frame = lis.length -1;
  13.  
  14.     start_slideshow(start_frame, end_frame, delay, lis);
  15. }
  16.  
  17. function start_slideshow(start_frame, end_frame, delay, lis) {
  18.     setTimeout(fadeInOut(start_frame,start_frame,end_frame, delay, lis), delay);
  19. }
  20.  
  21. function fadeInOut(frame, start_frame, end_frame, delay, lis) {
  22.     return (function() {
  23.         lis = $('slide-images').getElementsByTagName('li');
  24.         Effect.Fade(lis[frame]);
  25.         if (frame == end_frame) { frame = start_frame; } else { frame++; }
  26.         lisAppear = lis[frame];
  27.         setTimeout("Effect.Appear(lisAppear);", 0);
  28.         setTimeout(fadeInOut(frame, start_frame, end_frame, delay), delay + 1850);
  29.     })
  30. }
  31.  
  32. Event.observe(window, 'load', init, false);
-------
HTML:
-------
Expand|Select|Wrap|Line Numbers
  1. <head>
  2.     <script type="text/javascript" src="/libraries/prototype/prototype.js"></script>
  3.     <script type="text/javascript" src="/libraries/simple-slide-show.js"></script>
  4. </head>
  5.  
  6. ...
  7.  
  8. <div id="slide-show">
  9. <ul id="slide-images">
  10.  
  11. <li><a href="/">
  12. <img src="/template/images/new2/slider/slider1.png" alt="Target Link 1" />
  13. </a></li>
  14.  
  15. <li><a href="/">
  16. <img src="/template/images/new2/slider/slider2.png" alt="Target Link 2" />
  17. </a></li>
  18.  
  19. <li><a href="/">
  20. <img src="/template/images/new2/slider/slider3.png" alt="Target Link 3" />
  21. </a></li>
  22.  
  23. </ul>
  24. </div>
Dec 9 '09 #1
1 7435
Dormilich
8,658 Expert Mod 8TB
I’m not familiar with prototype, though I noticed
Expand|Select|Wrap|Line Numbers
  1.     for( i=0; i < lis.length; i++){
  2.         if(i!=0){
  3.             lis[i].style.display = 'none';
  4.         }
  5.     }
why not starting with 1 instead explicitly checking for 0?
Expand|Select|Wrap|Line Numbers
  1. // the somewhat strange looking first term is used to speed up the loop
  2. // because you calculate the length only once
  3.     for( var l, i=1, l=lis.length; i<l; i++){
  4.         lis[i].style.display = 'none';
  5.      }
Dec 10 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: engsol | last post by:
I'm using Python to parse a bunch of s/w test files and make csv files for later report generation by MS ACCESS....(my boss loves the quick turn-around compared to C). Each log file may contain one...
1
by: marius | last post by:
Hi! I'm trying to make myself a simple webpage, enabling me to stop and start certain services on the server. I've been doing some reading, and have given permission for ASPNET account to the...
7
by: shai | last post by:
I am working at .net 1.1, writing in c#. I have windows service with a COM object. Every unexpected time The COM object throw an error that make my service get stuck (do not respond). I can catch...
1
by: vikraman | last post by:
Request the script for Mouseover dispy of text at specific coordinats of an image/body and Mouseout disply of original image/body
3
by: vikraman | last post by:
I have a problem. See the Mouseover event below <head> <script type="text/javascript"> function writeText(txt) { document.getElementById("x").innerHTML=txt }
4
by: anj | last post by:
please provide me a syntax / command on how to create this tooltip (mouseover and mouseout) complete command. so i can apply it on my project.. please help me.. tnx
4
Wing
by: Wing | last post by:
Hello fellow programmers. I am writing a desktop application that will allow our IT department to execute commands on remote computers. I had originally found a post that has a two part program that...
0
vikas1111
by: vikas1111 | last post by:
Hi All.. I have created a slide show of some images using button,, now i want to stop the slide show when i mouseover the image or button, and restart the slide show when i move mouse out of...
1
by: delphi | last post by:
Hi all, I need help. I am new in javascript programming. And I had problem when I try to make a popup which showing another site. I had seen on few RL site. And I need to stop the countdown...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.