简体   繁体   中英

Can anyone please tell me why my navigation doesn´t work?

I can go to the different pages by clicking on MENU, but not back to the first page (index.php).

This is the Javascript function, which I put in the head:

function toggle_visibility(id) {
            var e = document.getElementById(id);
            e.style.display = (e.style.display === 'block') ? 'none' : 'block';
        }

This is the navigation in the body:

<nav>
            <a href="index.php" onclick="toggle_visibility('menu');
                    return false">
                MENU
            </a>

            <div id="menu" style="display:none;">
                <a href="seite1.php" onclick="toggle_visibility('submenu');
                        return false">
                    POINT1
                </a>
                <div id="submenu" style="display:none;">
                    <a href="seite2.php">
                        POINT 2
                    </a>
                    <a href="seite3.php">
                        POINT 3
                    </a>
                </div>

                <a href="seite4.php">
                    POINT 4
                </a>
                <a href="seite5.php">
                    POINT 5
                </a>
            </div> 

        </nav>

Thank you very much for helping... :)

the "return false" is preventing the normal action of the <a> link causing the link to not be functional.

you need to remove that in order for it to be a navlink.

   <a href="index.php" onclick="toggle_visibility('menu')">
        MENU
    </a>

I am trying to work out why you have the two return falses' in there but I can't see it - you are toggling the visibility of the menu and sub mienu, but I am not sure why the return false is needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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