I’d like to make the browser to scroll the page to a given anchor, just by using JavaScript.
I have specified a name or id attribute in my
name
id
Great solution by jAndy, but the smooth scroll seems to be having issues working in firefox.
Writing it this way works in Firefox as well.
(function($) { $(document).ready(function() { $('html, body').animate({ 'scrollTop': $('#anchorName2').offset().top }, 2000); }); })(jQuery);