简体   繁体   English

页面中的锚链接不起作用

[英]Anchor links in page not working

The site is http://differenzaus.com/ . 该网站是http://differenzaus.com/ Try any of the buttons on the page (eg, the one in the header "Work With Us," which is supposed to link to the "Contact" form). 尝试页面上的任何按钮(例如,标题为“与我们合作”中的按钮,该按钮应该链接到“联系”表单)。 The button appears active but when you click on it nothing happens. 该按钮显示为活动状态,但是当您单击它时,没有任何反应。 This wasn't a problem prior to last night. 昨晚之前这不是问题。 I'd fixed a close event on the slidebar menu, and after that the anchor/targets weren't working. 我修复了滑动菜单上的close事件,此后锚定/目标不起作用。

Any tips? 有小费吗? The source code is all available via view source. 源代码都可以通过查看源代码获得。

You added # to all of your href attributes. 您在所有href属性中添加了# If you hover over your buttons you will get ex. 如果将鼠标悬停在按钮上,则将得到ex。 #contact . #contact

Take a look in your code if you insert # . 如果您插入#请看一下您的代码。

It's due to some Javascript in there. 这是由于里面有一些Javascript。 The links are correct, and so are the section IDs. 链接正确,部分ID也正确。 If you deactivate Javascript completely, the links work. 如果您完全停用Javascript,则链接将起作用。 Probably some scolling script. 可能是一些脚本。 Deactivate the scripts one by one to find it and then try to find the error in the script. 逐个停用脚本以查找脚本,然后尝试在脚本中查找错误。

It looks like you're catching the click event that would allow the buttons to work, and using it exclusively to collapse the sidebar menu: 看起来您正在捕获使按钮能够工作的click事件,并专门使用它来折叠侧边栏菜单:

// Toggle main menu
    $( '[canvas]' ).on( 'click', function ( event ) {
        event.preventDefault();
        event.stopPropagation();
        controller.close( 'menuMain' );
    } );

Try removing the calls to preventDefault() and stopPropagation() , or wrap the event hander in an if statement that checks whether the sidebar is already open. 尝试删除对preventDefault()stopPropagation()的调用,或将事件处理程序包装在if语句中,以检查边栏是否已打开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM