a href not working!?

Discussion in 'HTML & Website Design' started by SirKhaal, Apr 5, 2018.

  1. #1
    Hi all,

    First time I see this issue. I have a really simple: <a href="/#!/something"> that just doesn't work... It changes the URL in the browser, but does not scroll to the section. In the same page, I have the exact same "a href" at another place and it works!

    page:
    http://creagrif.ca/

    Works in the menu bar, but not the 3 images at the top of the page.

    I have tried dozens of different syntax, can't make it work...

    Any ideas? Thanks!
     
    SirKhaal, Apr 5, 2018 IP
  2. SirKhaal

    SirKhaal Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    Finally got it working by replacing <a href="#!/something"> by <a href="#something">...

    I loose the smooth scrolling effect, but at least it works.

    I am still mesmerized by the fact that it works in the Wordpress menu, but not in the top section...
     
    SirKhaal, Apr 5, 2018 IP
  3. Paweł

    Paweł Active Member

    Messages:
    210
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #3
    Add this code (requires jQuery) to enable smooth scrolling:
    $('a[href^="#"]').on('click',function(e){
        html_tag.add(body_tag).animate({'scrollTop': $($(this).attr('href')).offset().top},1000,'easeInOutExpo');
        e.preventDefault();   
    });
    Code (markup):
     
    Paweł, Apr 5, 2018 IP