我正在创建一个响应式网站,所以当它处于移动尺寸时,导航会变成一个跳转菜单,这一切都很好,花花公子!
但是当我到达另一个页面时,跳转菜单上的更改页面什么时候跳转菜单的父级会停留在主页上,所以我不能再从另一个页面回到主页上,我怎么能这样说呢在主页上,我点击进入电子页面,在电气页面上,跳转菜单上有电动标记?
p.s我无法在每个页面上更改它,因为我在每个页面的同一个导航栏中拉动,下面是我正在使用的代码
<form name="form" class="mob-nav">
<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
<option value="index.php">Home</option>
<option value="how-it-works.php">How it works</option>
<option value="gas.php">Gas</option>
<option value="electric.php">Electric</option>
<option value="telecoms.php">Telecoms</option>
<option value="services.php">Services</option>
<option value="contact.php">Contact</option>
</select>
</form>
表示网站http://79.170.44.126/rkhconsultants.co.uk/
答案 0 :(得分:1)
用一些php修复它
<?
if ($PHP_SELF != '/rkhconsultants.co.uk/index.php')
{ $page1 = ''; } else { $page1 = 'selected'; }
if ($PHP_SELF != '/rkhconsultants.co.uk/how-it-works.php')
{ $page2 = ''; } else { $page2 = 'selected'; }
if ($PHP_SELF != '/rkhconsultants.co.uk/gas.php')
{ $page3 = ''; } else { $page3 = 'selected'; }
if ($PHP_SELF != '/rkhconsultants.co.uk/electric.php')
{ $page4 = ''; } else { $page4 = 'selected'; }
if ($PHP_SELF != '/rkhconsultants.co.uk/telecoms.php')
{ $page5 = ''; } else { $page5 = 'selected'; }
if ($PHP_SELF != '/rkhconsultants.co.uk/services.php')
{ $page6 = ''; } else { $page6 = 'selected'; }
if ($PHP_SELF != '/rkhconsultants.co.uk/contact.php')
{ $page7 = ''; } else { $page7 = 'selected'; }
?>
<form name="form" class="mob-nav">
<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
<option <?echo $page1;?> value="index.php">Home</option>
<option <?echo $page2;?> value="how-it-works.php">How it works</option>
<option <?echo $page3;?> value="gas.php">Gas</option>
<option <?echo $page4;?> value="electric.php">Electric</option>
<option <?echo $page5;?> value="telecoms.php">Telecoms</option>
<option <?echo $page6;?> value="services.php">Services</option>
<option <?echo $page7;?> value="contact.php">Contact</option>
</select>
</form>
答案 1 :(得分:0)
简而言之,您需要在选项元素
中添加selected
标记
<option selected value="electric.php">Electric</option>
因此,您需要通过PHP复制导航中添加类active
的代码。