473,549 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Slideshow stop on mouseover start on mouseout

1 New Member
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(my Timer)
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 7454
Dormilich
8,658 Recognized Expert Moderator Expert
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
5185
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 or more 'sessions', and each session may contain one or more 'nodes'. Each session in the log has an ASCII start and stop time, as does each...
1
2821
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 services I'd like to control, but then I get stuck on a "The RPC server is unavailable" error. It does give me a hint: "", but I haven't been able...
7
7216
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 this error. I want to restart my windows service every time the COM object throws an error. I use System.ServiceProcess.ServiceController to...
1
1995
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
2491
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
1409
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
3210
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 was working nicely for half our computers. It seems that when the remote portion (which is a service) is running other programs will get hung up....
0
2524
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 the image.. Can anyone please give me an idea how to solve this ?? Its urgent.... I am pasting my code what i have done so far.. function...
1
1947
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 timer until user click any links on the site in the popup and counting again, if can, then back to main window. How to do it? Thanks before
0
7541
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7464
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7734
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7979
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5107
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1960
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1074
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
781
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.