开发者

Ajax navigation without #!

I have noti开发者_如何学运维ced that sites like http://hypem.com which is a full ajax site have now managed to scrap their #! ajax urls but maintained a full ajax site. How is this possible?


You can do this with history.pushState, only in decent browsers though ;)

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

Here's a jQuery plugin with a fallback for older browsers to a hashed URL: http://plugins.jquery.com/project/history-js


Some modern browsers support history.pushState().

However, if you want to support older browsers that are still popular, you should use the hash fallback.


simply include your

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

and

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

after the include to jquery (1.7+) in the <head> and the plugin will ajax-navigate automaticaly in your website.

for any more customization, doc or answers you can go on github https://github.com/binarymind/jquery-navigate

hope it helps.

bastien


HTML5 has new History API. Demo is available at this url. http://html5demos.com/history/

https://github.com/browserstate/history.js has a very good support for this. Also history.js is plug able with jquery, mootools etc and supports HTML4 browsers too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜