Smooth scrolling with location hash updation and location hash check on page load <script type="text/javascript"> jQuery(function($){     $(document).ready(function(){         hash = window.location.hash;         if( hash !== "" ){             var hashh = hash.replace("#","");             var topp = $('a[name="'+ hashh +'"]').offset().top;             topp -= 125;             $('html, body').animate({                 scrollTop: topp             }, 800);         }         $("a.province-smooth-scroll").on('click', function(event) {             event.preventDefault();             if (this.hash !== "") {                 var hash = this.hash;                 var prov = jQuery(this).data('province');                 var topp = $('a[name="'+prov+'"]').offset().top;                 topp -= 125;                 $('html, body').animate({                     scrollTop: topp                 }, 800, function(){                     if(history.pushState) {                         history.pushState(null, null, hash);                     }                     else {                         window.location.hash = hash;                     }                 });             }         });     }); }); </script>