OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

href not linking to external url

  • Thread starter Thread starter Salihan Pamuk
  • Start date Start date
S

Salihan Pamuk

Guest
I downloaded a one pager template which is designed very strange. All hyperlinks are linking to sections on the page and it is using a data-link="" parameter.

Now I try to link one of the menu items to an external url with target _blank, but then it is looking for the url that I defined on the page itself (so it is looking for the section which is not there e.g. www.example.com/http://google.nl)

The links has a value on the href elements like this:

Code:
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>

So this doesn't work (also without the target _blank:

Code:
<li><a id="navorder" href="http://order.company.com" target="_blank">Order Now</a></li>

What technology is used here? And how can I link a new menu item to a external page?

EDIT:

I found the code that is handling the href:

Code:
$(".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;

});

And when I click the link it is giving me the following error in console:

Code:
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)

<p>I downloaded a one pager template which is designed very strange. All hyperlinks are linking to sections on the page and it is using a data-link="" parameter.</p>

<p>Now I try to link one of the menu items to an external url with target _blank, but then it is looking for the url that I defined on the page itself (so it is looking for the section which is not there e.g. www.example.com/<a href="http://google.nl" rel="nofollow noreferrer">http://google.nl</a>)</p>

<p>The links has a value on the href elements like this: </p>

<pre><code>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>
</code></pre>

<p>So this doesn't work (also without the target _blank:</p>

<pre><code><li><a id="navorder" href="http://order.company.com" target="_blank">Order Now</a></li>
</code></pre>

<p>What technology is used here? And how can I link a new menu item to a external page?</p>

<p><strong>EDIT:</strong></p>

<p>I found the code that is handling the href:</p>

<pre><code>$(".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;

});
</code></pre>

<p>And when I click the link it is giving me the following error in console:</p>

<pre><code>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)
</code></pre>
 

Latest posts

Top