0

当您将鼠标悬停在我网站上的链接上时,它会显示正确的 URL,但是一旦您单击它,它就会添加一个 # 以阻止加载正确的页面。如何在我的网站上禁用 hashchange:

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

<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="javascript: void(0)" 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">

我认为我需要编辑的部分在 actions.js 中,但我不确定我需要更改什么

    $(window).hashchange();
});

function runSetups() {
    interceptLinks();
    setupHomeGallery();
    setupProjects();
    setupProject();
    setupNews();
    setupBackToTop();
    setupStickies();
}

function setupWindowEvents() {
    $(window).scroll(checkScrolling);

    $(window).hashchange(function () {
        var hash = location.hash;

        loadContent(hash.substr(1));
    });

    $(document).mousemove(function (event) {
        var mx = event.pageX;
        var my = event.pageY;

        if ($('#menuNav.open').length > 0) {
            if (my > $('#header').outerHeight() + 70) {
                $('#menuNav .closeNav').trigger('click');
                $('#menuNav').removeClass('open');
            }
        }
    });
4

1 回答 1

0

你的问题不在于你的script.js,而是你的action.js,你的href被加载到这个函数loadContent(url)中。然后,您的 href 将被转换为带有 location.hash 的哈希链接。您在这里有几个选择.. 如果您不使用它,您可以删除该功能,将 location.hash 更改为 window.location 或通过省略“/”来更改您的 href。

这真的取决于你想做什么。

于 2012-02-08T11:43:11.577 回答