I recently downloaded a one pager template that has a unique design. All the hyperlinks within the template are set to link to specific sections on the page and use a data-link="" parameter.
However, I encountered an issue when trying to link one of the menu items to an external URL with target _blank. Instead of directing me to the external page, it was looking for a section on the same page based on the URL I provided (e.g., www.example.com/).
The links in the template have href values like this:
href="/home/" or href="/menu/"
<ul id="w1" class="navbar-nav nav">
<li><a id="navhome" class="" href="/home" title="Home" data-link="home">Home</a></li>
<li><a id="navmenu" class="" href="/menu" title="Menu" data-link="menu">Menu</a></li>
Even when attempting without target _blank, the external linking did not work:
<li><a id="navorder" href="http://order.company.com" target="_blank">Order Now</a></li>
I am curious to know what technology is being used here and how I can successfully link a new menu item to an external page.
UPDATE:
I managed to locate the code responsible for handling the href:
$(".menu ul li a").not('.social-link').click(function(e) {
e.preventDefault();
$(".menu ul li a").removeClass("active");
tabTarget = $(this).data('link');
animateByMenu = true;
var hash = '#' + tabTarget;
var url = $(this).prop('href');
var menuItem = $(this).data('link');
$(".menu li a[data-link=" + menuItem + "]").addClass("active");
if (url) {
var top = $(hash).offset().top - 60;
$('html, body').animate({
scrollTop: top
}, 600, function(){
});
history.pushState('', '', url);
$('.navbar-toggle:visible').click();
}
return false;
});
Upon clicking the link, I am receiving the following error in the console:
main.js:109 Uncaught TypeError: Cannot read property 'top' of undefined
at HTMLAnchorElement.<anonymous> (main.js:109)
at HTMLAnchorElement.dispatch (jquery.min.js:3)
at HTMLAnchorElement.r.handle (jquery.min.js:3)