使用HTML5 History API的好教程(Pushstate?) [英] Good tutorial for using HTML5 History API (Pushstate?)

查看:126
本文介绍了使用HTML5 History API的好教程(Pushstate?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究如何使用HTML5 History API来解决AJAX加载内容的深层链接问题,但我正在努力实现目标。有没有人知道任何好的资源?



我想使用这个,因为它似乎是一种很好的方式来允许那些被发送的链接的可能性可能没有JS打开。当有人用JS发送链接给某人时,许多解决方案都失败了。



我最初的研究似乎指向JS中的History API和pushState方法。 >

http://html5demos.com/history

解决方案

对于一个很好的教程,关于这个功能的Mozilla开发者网络页面是你需要的: https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history



不幸的是,HTML5 History API在所有HTML5浏览器中的实现方式不同(使其不一致和错误)并且没有HTML4浏览器的后备。幸运的是, History.js 为HTML5浏览器提供了交叉兼容性(确保所有的HTML5浏览器都能像预计),并可选择为HTML4浏览器提供散列回退(包括对数据,标题,pushState和replaceState功能的维护支持)。



您可以阅读更多关于History.js这里:
https://github.com/browserstate/history.js p>

有关Hashbangs VS Hashes VS HTML5 History API的文章,请参阅此处:
https://github.com/browserstate/history.js/wiki/Intelligent-State-Handling


I am looking into using the HTML5 History API to resolve deep linking problems with AJAX loaded content, but I am struggling to get off the ground. Does any one know of any good resources?

I want to use this as it seems a great way to allow to the possibility of those being sent the links may not have JS turned on. Many solutions fail when someone with JS sends a link to someone without.

My initial research seems to point to a History API within JS, and the pushState method.

http://html5demos.com/history

解决方案

For a great tutorial the Mozilla Developer Network page on this functionality is all you'll need: https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history

Unfortunately, the HTML5 History API is implemented differently in all the HTML5 browsers (making it inconsistent and buggy) and has no fallback for HTML4 browsers. Fortunately, History.js provides cross-compatibility for the HTML5 browsers (ensuring all the HTML5 browsers work as expected) and optionally provides a hash-fallback for HTML4 browsers (including maintained support for data, titles, pushState and replaceState functionality).

You can read more about History.js here: https://github.com/browserstate/history.js

For an article about Hashbangs VS Hashes VS HTML5 History API, see here: https://github.com/browserstate/history.js/wiki/Intelligent-State-Handling

这篇关于使用HTML5 History API的好教程(Pushstate?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆