0

我正在制作一个响应式网站,所以当它是移动大小时,导航变成了一个跳转菜单,这一切都很好而且花花公子!

但是当我到达另一个页面时跳转菜单上的页面更改时跳转菜单的父级停留在主页上,所以我无法从另一个页面上点击主页,我该怎么做所以说我在主页上然后我点击进入电气页面,在电气页面上,跳转菜单勾选了电气?

ps 我不能在每个页面上更改它,因为我在每个页面上都拉入相同的导航栏,下面是我目前使用的代码

<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/

4

2 回答 2

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>
于 2013-03-05T15:53:43.453 回答
0

简而言之,您需要selected在选项元素内添加标签

 <option selected value="electric.php">Electric</option>

因此,您需要复制active通过 PHP 在导航中添加类的代码。

于 2013-03-05T15:41:48.503 回答