disable hashchange



当你将鼠标悬停在我网站上的链接上时,它会显示正确的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');
            }
        }
    });

您的问题不在于script.js是什么,而在于action.js将href加载到此函数loadContent(url)中的位置。然后,您的href将被转换为位置为.hash的哈希链接。您在这里有一些选择。。如果您不使用该函数,您可以删除它,将location.hash更改为window.location,或者通过省略"/"来更改href。

这实际上取决于你想做什么。

相关内容

  • 没有找到相关文章

最新更新