The script itself is relatively straight-forward too. Add the following code to the empty function at the bottom of the HTML file:
var parent = document.getElementById("post"), speed = 7, win = $(window); $("nav a", parent).click(function(e) { e.preventDefault(); var target = $(this).attr("href"), offset = $(target).offset(), newScroll = 0, maxScroll = document.body.scrollHeight; while (newScroll < offset.top && win.scrollTop() < maxScroll) { win.scrollTop(newScroll); newScroll = newScroll + speed; } }); $(".top", parent).click(function(e) { e.preventDefault; var newScroll = win.scrollTop(); while (newScroll > 0 && win.scrollTop() > 0) { win.scrollTop(newScroll); newScroll = newScroll - speed; } });
Save the HTML file again and run it in a browser. You should find that the document smoothly scrolls to the desired location when any of the top links on the page...