0

I am really new and my last question wasn't correct so here I go again. I was able to get the scroll to work to go to the top and bottom but right now it just snaps there and back. I want to give it a movement. Any help would be appreciated.

Here is my code:

document.getElementById('sur2').onclick = function () {
    document.getElementById('pt1').style.display='block';
    document.getElementById('pt2').style.display='none';
    window.scroll(0,0); 


}


document.getElementById('sur1').onclick = function () {
    document.getElementById('pt1').style.display='none';
    document.getElementById('pt2').style.display='block';
    window.scroll(0,5000);

}
Branislav Lazic
  • 14,388
  • 8
  • 60
  • 85
farmerm3
  • 341
  • 1
  • 4
  • 13
  • there are a lot of "smooth scroll" plugins and stand-alone routines out there, just search for one and ask if you get stuck implementing it. – dandavis Oct 10 '13 at 19:21
  • duplicate of http://stackoverflow.com/questions/19302053/i-am-trying-to-make-my-page-scroll-slower-when-you-press-a-button-using-jquery/19302204#19302204 – Pricey Oct 10 '13 at 19:34
  • @Pricey - the question you linked is about JQuery, while this one is about pure js. – Rafael Herscovici Oct 11 '13 at 04:28
  • @Dementic ok yes but it was the same person with the same code asking to do the same thing with a removed tag. This doesn't need 2 questions just specify js or jquery or ask for "with and without jQuery" examples. Applying a speed to a cross browser scroll just with javascript is a bit more advanced when the OP states they are new to jQuery when it wasn't jQuery to begin with. I have also added an answer for what they are doing to that other question using jQuery, so maybe someone won't waste their time doing the same thing again. – Pricey Oct 11 '13 at 09:17

1 Answers1

0

Instead of trying and re-inventing the wheel, You could use a ready made script and modify it to your likings. a pretty nice script i know in plain javascript would be http://cferdinandi.github.io/smooth-scroll/

if you need help implementing it, or have problems modifying it, ask a question.

Rafael Herscovici
  • 16,558
  • 19
  • 65
  • 93