[英]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).我可以通过单击 MENU 转到不同的页面,但不能返回第一页 (index.php)。
This is the Javascript function, which I put in the head:这是我放在头中的 Javascript 函数:
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. “return false”阻止了
<a>
链接的正常操作,导致链接无法正常工作。
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.我试图弄清楚为什么你在那里有两个返回假但我看不到它 - 你正在切换菜单和子菜单的可见性,但我不确定为什么需要返回假。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.