简体   繁体   English

导航链接不起作用(Bootsrap)

[英]Navigation Links Not Working (Bootsrap)

I am altering a Bootstrap-based template. 我正在更改基于Bootstrap的模板。 The original site was a single-page with the top nav links simply scrolling to the correct section of the page. 原始站点是一个单页,顶部的导航链接只是滚动到页面的正确部分。 I've added some a couple of other pages, and I want the navbar links to return the users to the appropriate section of the home page. 我添加了一些其他页面,并且我希望导航栏链接将用户返回到主页的相应部分。

However, when I've edited the links on the other page (not the main page) refer back to the home page, the links aren't working. 但是,当我编辑了另一页(而不是主页)上的链接时,请返回首页,这些链接不起作用。

I'm sure there is something in the js files that is breaking the default mode and keeping it on the home page. 我确定js文件中有东西会破坏默认模式,并将其保留在主页上。

The problem is that I don't know what to edit to stop this. 问题是我不知道要停止什么编辑。

The homepage is http://jimbrink.org . 主页是http://jimbrink.org The scrolling links work there. 滚动链接在那里工作。

The page where the links don't work is: http://jimbrink.org/articles 链接不起作用的页面是: http : //jimbrink.org/articles

Here's the html for the bar: 这是栏的html:

<div class="navbar navbar-default navbar-fixed-top" role="navigation" id="navbar">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#intro">JimBrink.org</a>
        </div>

        <div class="navbar-collapse collapse" id="navigation">

            <ul class="nav navbar-nav navbar-right">
                <li><a href="http://jimbrink.org/#intro">Intro</a>
                </li>
                <li><a href="http://jimbrink.org/#about">About</a>
                </li>
                <li><a href="http://jimbrink.org/#resources">Resources</a>
                </li>
                <li><a href="http://jimbrink.org/#impact">Impact</a>
                </li>
            </ul>
        </div>
        <!--/.nav-collapse -->

    </div>
</div>
<!-- /#navbar -->

<!-- *** NAVBAR END *** -->

Sorry for the newbie question. 对不起,新手问题。

UPDATE Fixed it. UPDATE修复它。 The #navigation tag was just for the js function that interrupted the default action when clicked. #navigation标签仅用于js函数,该函数在单击时会中断默认操作。 I just removed that ID and it worked. 我刚刚删除了该ID,它就起作用了。

When you are clicking in "About" in menu, it has as href value " http://jimbrink.org/#about " and based in JS it has to move in section with id "about". 当您在菜单中单击“关于”时,它具有href值“ http://jimbrink.org/#about ”,并且基于JS,它必须在ID为“关于”的部分中移动。 In your HTML page you don't have any section with ID "#about". 在您的HTML页面中,没有ID为“ #about”的任何部分。 You need to add to about section id about. 您需要添加到关于部分ID关于。 You need to match the sections IDs with the values of menu items href value, because when you are clicking it shows a JS error and cannot scroll to the section. 您需要将部分ID与菜单项href值的值进行匹配,因为单击时会显示JS错误,并且无法滚动到该部分。

Uncaught TypeError: Cannot read property 'slice' of undefined

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

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