I am using the following script to make a sliding effect between the sections of my site (links with anchors, P.E. #contact). While on my menu it has an external link, how do I make it work?
$(function() {
var navH = $('body > .nav').outerHeight(true);
$('body').css({
"margin-top": navH + "px"
});
$('body > nav .container-fluid .navbar-collapse .nav ').on("click", 'a', function(e) {
e.preventDefault();
var target = $(this).attr("href"),
elementOffset = $(target).offset().top,
distance = (elementOffset - navH);
$("html, body").stop(true, true).animate({
scrollTop: distance
}, '500', 'swing', function() {
$('body > .nav .active').removeClass("active");
$('a[href="' + target + '"]').parent().addClass('active');
});
});
});