我正在使用php将活动链接状态添加到我的导航菜单中,该菜单在我的所有网站页面中动态共享。但是,当我从主页上转到其他链接时,它工作正常,但当我回到主页时,它会给我“找不到对象”错误。
<!--start vertical menu-->
<?php
$index="menu-items";
$top_albums_default="menu-items";
$Topartists="menu-items";
$Toplists="menu-items";
$Charts="menu-items";
$menuLinkid=basename($_SERVER['PHP_SELF'],".php");
if($menuLinkid=="index"){
$index='active';
}else if ($menuLinkid=="top_albums_default"){
$top_albums_default='active';
}else if ($menuLinkid=="Topartists"){
$Topartists='active';
}else if ($menuLinkid=="Toplists"){
$Toplists='active';
}else if ($menuLinkid=="Charts"){
$Charts='active';
}
?>
<div id="vertical-menu">
<!--<h2 class="logo">LOGO</h2>-->
<img class="logo" src="../Graphics/icons/logo.png" alt="LOGO"/>
<h6 class="logo-desc">Arcade Music Repository</h6>
<ul class="menu-items">
<li>
<a class="<?php echo $index; ?>" href="index.php" ><i class="arcd-archive" ></i></br>Browse</a>
</li>
<li>
<a class="<?php echo $top_albums_default; ?>" href="Top-albums/top_albums_default.php"><i class="arcd-music97"></i></br>Top albums</a>
</li>
<li>
<a href="../Top-artists/top-artists_default.php"><i class="arcd-microphone52"></i></br>Top artists</a>
</li>
<li>
<a href="../Top-lists/top-lists_default.php"><i class="arcd-numbered8"></i></br>Top lists</a>
</li>
<li>
<a href="../Charts/Charts_default.php"><i class="arcd-rising9"></i></br>Charts</a>
</li>
</ul>
</div>
<script type="text/javascript" src="../js/jquery-1.11.3.min.js"> </script>
答案 0 :(得分:0)
您在首页链接上缺少正斜杠。
像这样:
<ul class="menu-items">
<li>
<a class="<?php echo $index; ?>" href="/index.php" ><i class="arcd-archive" ></i></br>Browse</a>
</li>