Geeks With Blogs

News

Agha Usman Ahmed JILAWATAN

Having a marquee on a page is not a big deal but what if somebody wants user to adjust the speed of the moving text. So the idea is we have many marquee in one page and we want to adjust their speed using two javascript Buttons called “Speed Up” and “Speed Down”

The logic is very simple, the marquee tags which you want to control with the help of buttons give them name in my case it is “Scrollers” (Remember it is name not id, so you can give same name to as many controls).

Now call the following function on “Speed Up” and “Speed Down” button respectively.

   1: function speedUp() 
   2: {
   3:     var obj = document.getElementByName("scrollers")
   4:     
   5:     for (i=0;i<=obj.Length -1;i++) 
   6:     {
   7:         obj[i].scrollAmount = obj[i].scrollAmount * 3 - obj[i].scrollAmount
   8:     }
   9: }
  10:  
  11: function speedDown() 
  12: {
  13:     var obj = document.getElementByName("scrollers")
  14:     
  15:     for (i=0;i<=obj.Length -1;i++) 
  16:     {
  17:         obj[i].scrollAmount = obj[i].scrollAmount * (10/7) - obj[i].scrollAmount
  18:     }
  19: }

That’s it

Posted on Monday, February 16, 2009 4:00 PM Javascript Tricks | Back to top


Comments on this post: Dynamically control the scroll amount of marquee

# re: Dynamically control the scroll amount of marquee
Requesting Gravatar...
Thanks, your,ve just solved a big problem
Left by Samuel on Sep 17, 2009 12:13 AM

Your comment:
 (will show your gravatar)


Copyright © Agha Usman Ahmed | Powered by: GeeksWithBlogs.net