不带#的Ajax导航

Ajax navigation without #!

本文关键字:导航 Ajax 不带      更新时间:2023-09-26

我注意到http://hypem.com这是一个完整的ajax站点,现在已经设法废弃了它们的#!ajax网址,但维护了一个完整的ajax站点。这怎么可能?

您可以使用history.pushState来做到这一点,但只能在不错的浏览器中;)

https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history

下面是一个jQuery插件,它为旧浏览器提供了一个散列URL的回退:http://plugins.jquery.com/project/history-js

一些现代浏览器支持history.pushState()

但是,如果您想支持仍然流行的旧浏览器,则应该使用哈希回退。

只需包含

<script type="text/javascript" src="https://raw.github.com/binarymind/jquery-navigate/master/navigate.js" ></script>

<script type="text/javascript"
$(document).ready(function() {
    $.navigate.init();
});
</script>

<head>中包含jquery(1.7+)之后,插件将在您的网站中自动进行ajax导航。

对于更多的定制、文档或答案,您可以访问githubhttps://github.com/binarymind/jquery-navigate

希望能有所帮助。

bastien

HTML5有了新的历史API。此网址提供演示。http://html5demos.com/history/

https://github.com/browserstate/history.js对此有很好的支持。此外,history.js可与jquery、mootools等插件配合使用,并支持HTML4浏览器。