Smooth scroll with external link

时间:2017-06-09 12:49:37

标签: jquery

I have a simple menu with 3 anchor and 1 external link. I am using this for smooth scrolling:

        $('.header-menu a').on('click', function (e) {
            e.preventDefault();

            var target = this.hash,
                $target = $(target);

            $('html, body').stop().animate({
                'scrollTop': $target.offset().top - 55
            }, 700, 'swing');
        });

which works great with anchor links but it doesnt work on external link in the menu. When i remove e.preventDefault();, then it works, but there is weird page flicker when i click on the links.

What is the solution to enable external links? Thanks!

0 个答案:

没有答案