Smooth scroll with HTML bookmarks
// HTML Bookmarks smooth scroll, clicked on any bookmarked anchor,
// do animated scroll to it's target element.
// jQuery Required
// Update 31st May to scroll for extrnal pages.
(function($){
var h = window.location.hash;
if( h.length > 1 ) {
var target = $(h);
if( target.length ) {
$('html,body').animate({ scrollTop: target.offset().top },400);
}
}
$(document).on('click','a',function(e){
var a = $(this), href = a.attr('href');
if(href && ~href.indexOf('#')){
var name = href.substr( href.indexOf('#') + 1 ), target = $('a[name='+ name +']'), target2 = $('#' + name);
console.log(name);
target = (target.length)? target : target2;
if(target.length){
e.preventDefault();
$('html,body').animate({
scrollTop: target.offset().top
},400);
}
}
});
})(jQuery);
// Menified Version of Smooth scrool Script given below:
(function(b){var c=window.location.hash;1<c.length&&(c=b(c),c.length&&b("html,body").animate({scrollTop:c.offset().top},400));b(document).on("click","a",function(c){var a=b(this).attr("href");if(a&&~a.indexOf("#")){var a=a.substr(a.indexOf("#")+1),d=b("a[name="+a+"]"),e=b("#"+a);console.log(a);d=d.length?d:e;d.length&&(c.preventDefault(),b("html,body").animate({scrollTop:d.offset().top},400))}})})(jQuery);