Google Gears / HTML5 的 JavaScript 包装器
是否有任何 JavaScript 包装脚本可以使用 HTML5 JavaScript 功能(如果可用)(例如 locaStorage/Web 存储/Google Gears 和 HTML5 之间的任何共同点),如果浏览器不支持(例如 IE6 或 IE7),则回退到 Google Gears )
虽然 IE7/6 用户全部迁移到 IE8(或 Chrome、Firefox、Opera)是理想的情况,但它们在未来几年仍将存在(也许 IE6 不会像 IE7 持续那么久,但 IE7 缺乏任何真正的 JavaScript变化)。
Are there any JavaScript wrapper scripts available that can use HTML5 JavaScript features if they are available (e.g. locaStorage / Web Storage / anything in common between Google Gears and HTML5), falling back to Google Gears if the browser is not capable (e.g. IE6 or IE7)
While it would be ideal that IE7/6 users all move to IE8 (or Chrome, Firefox, Opera), they will still be around for years to come (maybe IE6 will not last as long as IE7, but IE7 lacks any real JavaScript changes).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于功能检测,我认为这里的大多数人会推荐优秀的 Modernizr。当然,您仍然需要自己编写 Gears 部分,但这确实不是很难 - 只是在 Modernizr 报告您正在寻找的功能不可用后进行二次测试,或者使用以下命令创建您自己的测试
addTest()
API。您尝试使用 Gears 作为这些 HTML5 组件的后备,这听起来有点奇怪 - 据我所知,Gears 的渗透率非常低,所以它不可能真的是为那些人提供可靠的后备。尽管功能相似,但语法不同,因此您实际上需要为不太可能使用的东西编写两倍的代码。
For feature detection I think most here would recommend the excellent Modernizr. Of course you'd still have to write the Gears part yourself, but that really isn't very hard - just a secondary test after Modernizr reporting back that the features you're looking for isn't available, or creating your own test with the
addTest()
API.It comes across as a little odd that you're trying to use Gears as a fallback for those HTML5 components - as far as I can tell, Gears penetration is very low, so it can't really be an reliable fallback for those. Although the functionality is similar, the syntax isn't, so you really are going to be writing twice the amount of code for something that's unlikely to be used.
虽然我不知道这样的包装器,但可以使用旧的故障保护:
While I don't know of such wrappers, one can use the old failsafe:
http://www.phonegap.com/ (据我到目前为止所能推测的 - 这使用本机代码)
https://github.com/zefhemel/persistencejs
http://code.google.com/p/webstorageportabilitylayer/
http://www.modernizr.com/
http://www.phonegap.com/ (from what I've been able to divine so far - this uses native code)
https://github.com/zefhemel/persistencejs
http://code.google.com/p/webstorageportabilitylayer/
http://www.modernizr.com/