Javascript菜单onclick不起作用

时间:2012-02-07 23:15:36

标签: javascript wordpress

我在我在Wordpress中创建的网站上创建了一个展开/折叠菜单

http://www.ogormanconstruction.co.uk/

点击任何一个li后,网址会发生变化,但网页似乎没有刷新以显示正确的内容

我对javascript不太熟悉所以我想知道如何让这个效果起作用

<script type='text/javascript' src="/wp-content/themes/child/scripts/jquery-1.6.2.min.js"></script>
<script type='text/javascript' src="/wp-content/themes/child/scripts/jMaster.js"></script>
<script type='text/javascript' src="/wp-content/themes/child/scripts/supersleight.plugin.js"></script>
<script type="text/javascript" src="/wp-content/themes/child/scripts/hashchange.js"></script>
<script type="text/javascript" src="/wp-content/themes/child/scripts/actions.js"></script>
<script type="text/javascript" src="/wp-content/themes/child/scripts/tinyscroll.js"></script>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['aspnetForm'];
if (!theForm) {
    theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>
</head>

<body <?php body_class(); ?>>

<div id="header">
            <ul id="nav">
                <li class="clearfix">
                    <div class="clearfix">
                        <div id="menuNav"><a href="#" class="openNav">Menu</a></div>
                        <ul class='clearfix'><li><strong>O'Gorman Construction Ltd</strong><ul class='clearfix'><li><a href='/about-us'>About Us</a><li><a href='/contact'>Contact</a></li></li><li><a href='/work'>Work</a></li><li><a href='/recruitment'>Recruitment</a></li></ul></li><li><strong>Services</strong><ul class='clearfix'><li><a href='/site-logistics'>Labour Supply</a></li><li><a href='/waste-management'>Drainage</a></li><li><a href='/security-services'>Fencing</a></li><li><a href='/traffic-management'>Demolition</a></li></ul></li><li><strong>&nbsp;</strong><ul><li><a href='/multi-service-gangs'>Ground Works</a></li><li><a href='/facilities-accomodation'>Multiservice Gangs</a></li><li><a href='/small-works-maintenance'>Engineering</a></li><li><a href='/catering-services'>Water Treatment</a></li></ul></li></ul>
                    </div>
                    </div>
                </li>
            </ul>
            <a href="/" id="logo"></a>
        </div>

<h2>Work</h2>
<div class="leftCol">
<div class="rightCol gallery">
    <ul id="homeGallery">
<li id="prevControl"><a href="#">Previous</a></li>
        <li id="galleryItems">

                    <ul>

                    <li>
                        <div class="galleryImage"><img src='/wp-content/themes/child/images/1.jpg' /></div>
                        <div class="galleryText"><div class="leftCol noborder" style="text-align: left;"><strong>Project I</strong></div></div>
                    </li>

                    <li>
                        <div class="galleryImage"><img src='/wp-content/themes/child/images/2.jpg' /></div>
                        <div class="galleryText"><div class="leftCol noborder" style="text-align: left;"><strong>Project II</strong></div></div>
                    </li>

                    <li>
                        <div class="galleryImage"><img src='/wp-content/themes/child/images/4.jpg' /></div>
                        <div class="galleryText"><div class="leftCol noborder" style="text-align: left;"><strong>Project III</strong></div></div>
                    </li>

                    </ul>

        </li>

<li id="nextControl"><a href="#">Next</a></li>
        <li id="copyright">&copy; O'Gorman Construction Ltd</li>
    </ul>
</div>
</div>


    <div id="main">

1 个答案:

答案 0 :(得分:1)

您在

中调用的$(window).hashchange();看起来很像
$(document).ready(function ()

我认为它会导致页面中的所有链接添加哈希而不是重定向到其他网址。

例如,如果您将鼠标悬停在“工作”链接上,则可以在左下角看到它应该显示的网址:

http://www.ogormanconstruction.co.uk/work

但是当你点击它时,所发生的一切都是url改为:

http://www.ogormanconstruction.co.uk/#/work

实际上并没有重定向你。

是否是Wordpress的hashchange部分,或者是你添加了什么?