$('html').css({display: 'none'}); $(document).ready(function(){ var hashURL = location.hash; if(hashURL != '' && hashURL.length > 1){ $('html, body').scrollTop(0); $('html').css({display: 'block'}); smoothScrollTo(hashURL); } else { $('html').css({display: 'block'}); } }); /** * Method smooth scrolls to given anchor point */ function smoothScrollTo(anchor) { var duration = 3000; //time (milliseconds) it takes to reach anchor point var targetY = $(anchor).offset().top; $("html, body").animate({ "scrollTop" : targetY }, duration, 'easeInOutCubic'); }