以下脚本可与IE9和Chrome 18配合使用,但会导致Firefox 11刷新不休。

<script type="text/javascript">
$(document).ready(function () {
    if (window.location.href.indexOf('#') == -1) {
        window.location.hash = 'Value';
        //window.location.href += 'Value';
    }
});
</script>


最好的祝福,

莱泽克

最佳答案

我猜想更改哈希会再次在firefox上导致document.ready。该脚本将看到href中没有哈希符号,然后再次对其进行更改。 Presto,无限循环。我会用这段代码

$(document).ready(function () {
    if (window.location.hash.length == 0) {
        window.location.hash = '#Value';
    }
});

关于javascript - jQuery添加location.hash无休止地刷新Firefox,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10227006/

10-10 13:26
查看更多