$(document).ready(function(){ $('a[href*=#]').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']'); if ($target.length && this.hash.slice(1)!="") { window.open("#","_self"); var targetOffset = $target.offset().top; $('html,body') .animate({scrollTop: targetOffset}, 600); return false; } } }); if (location.href.indexOf("#")>0) { var $target = location.href.split("#"); $target = $target[1]; if ($target!="") { $target = $('[name=' + $target +']'); window.open("#","_self"); var targetOffset = $target.offset().top; $('html,body').animate({scrollTop: targetOffset}, 600); return false; } } });
