0

I want to write an Jquery or JS script to scroll down a given page if it has the vertical scrollbar. This is to automate the web page navigation using the mouse wheel, so I should be able to animate it with time.

I was reading the web but seems that to do something like this you need to know an element name. Is it possible without knowing any element name? Something like $(document).scrollDown(speed)?

samsamara
  • 4,630
  • 7
  • 36
  • 66
  • possible duplicate http://stackoverflow.com/questions/4034659/is-it-possible-to-animate-scrolltop-with-jquery – zb' Oct 06 '13 at 07:36

2 Answers2

1

You could animate scrollTop property of html and body elements, like this:

 $(window).load(function() {
   $("html, body").animate({ scrollTop: yPosition }, 1000);
 });

In this snippet, yPosition represents the height you want to reach, and 1000 controls the speed.

Guillaume Poussel
  • 9,572
  • 2
  • 33
  • 42
1

To detect if the page has a vertical scroll bar you could do:

if((document).height() > (window).height())
{
   $('html').animate({scrollTop : ((document).height()},'slow');
}
Patrick Geyer
  • 1,515
  • 13
  • 30