开发者

Manually add url to history with jquery

I'd like for my site to allow navigation, but I don't like the applications of all the history plug-ins. Most or all of them use a hashtag, which doesn't really apply to my site. I want to maintain clean urls, and often it just won't make sense to simply add a hashta开发者_开发知识库g to the current url.

So what I'd like to accomplish is whenever a user clicks on certain links, I will artificially add a url to the history. If the user refreshes or clicks back, it should then navigate to that url, which will exist on its own. It doesn't have to do this part with ajax, that's fine.

Example: a user is on http://www.abc.com/page1.php. If they click a link for page 2, ajax will populate the current page. The url should now read http://www.abc.com/page2.php, and the user can click back to go back to page 1, or click refresh to stay on page2. page 1 and page 2 can both be bookmarked, that's not a problem.

The best example I can think of is the way facebook can navigate through photos


This plugin might help you.

History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles and replaceState. Supports jQuery, MooTools and Prototype. For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜