0

the script shown here works at link but not works when i put inside web site, what is wrong ?http://jsfiddle.net/QUCWe/

//<![CDATA[ 
$(window).load(function(){
function scroll(speed) {
    $('html, body').animate({ scrollTop: $(document).height() - $(window).height() }, speed, function() {
        $(this).animate({ scrollTop: 0 }, speed);
    });
}

speed = 1000;

scroll(speed)
setInterval(function(){scroll(speed)}, speed * 2);
});//]]>  
elit elit
  • 22
  • 7
  • I think that you haven't jQuery... What is it in console? – Krzysiek Sep 05 '13 at 20:21
  • i have jquery, for example other codes in this topic , but only the code above is not work ; http://stackoverflow.com/questions/8107251/automatically-scroll-page-from-top-to-bottom-then-back-up-and-repeat – elit elit Sep 05 '13 at 20:28
  • 2
    You should change `$(window).load(function()` with `$(function()` – Krzysiek Sep 05 '13 at 20:32
  • thank you Krzysiek i ll try tomorrow i hope it can work – elit elit Sep 05 '13 at 20:33
  • Load event on window sometimes can never fire (eg. when is attached after page load). – Krzysiek Sep 05 '13 at 20:36
  • Hi, i tried but problem still continue, the other code i have use `$(window).load(function()`and no problem. in this code problem is somewhere here `setInterval(function(){scroll(speed)}, speed * 2);` if i delete this row it works well but scroll only one time from top to bottom andd back, than stop, i would like it make continious. – elit elit Sep 06 '13 at 04:44

1 Answers1

0

i change speed * 2 and it worked;

//<![CDATA[ 
$(window).load(function(){
function scroll(speed) {
    $('html, body').animate({ scrollTop: $(document).height() - $(window).height() }, speed, function() {
        $(this).animate({ scrollTop: 0 }, speed);
    });
}

speed = 1000;

scroll(speed)
setInterval(function(){
scroll(speed)
}, 3000);
});//]]> 
elit elit
  • 22
  • 7