ECMAScript 5与HTML5 的支持情况
ECMAScript 5与HTML5离我们越来越近了,触摸屏相关的API开发中,未来的web世界更加多姿多彩。
Object.getPrototypeOf
支持浏览器:firefox3.6 chrome4
http://codereview.chromium.org/518056
Object.getOwnPropertyDescriptor
支持浏览器:IE8 chrome4
http://code.google.com/p/chromium/issues/detail?id=20345
Object.keys
支持浏览器: chrome4
http://code.google.com/p/chromium/issues/detail?id=21767
Object.defineProperty
支持浏览器: IE8
http://msdn.microsoft.com/en-us/library/dd548687(VS.85).aspx
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object/defineProperty
Object.create
支持浏览器: chrome4
http://msdn.microsoft.com/en-us/library/dd548687(VS.85).aspx
Object.getOwnPropertyNames
支持浏览器: chrome4
http://code.google.com/p/v8/source/detail?r=3620
关于Object的扩展,可以看John Resig的这一篇博文《ECMAScript 5 Objects and Properties》
JSON
支持浏览器: IE8 chrome1+ safari3+ firefox3+
JSON.parse( text, translate ) JSON.stringify( obj, translate ) String.prototype.toJSON Boolean.prototype.toJSON Number.prototype.toJSON Date.prototype.toJSON |
http://blog.mozilla.com/webdev/2009/02/12/native-json-in-firefox-31/
http://blogs.msdn.com/ie/archive/2008/09/10/native-json-in-ie8.aspx
Date.now
支持浏览器: chrome4 firefox2+ safari4
Date.prototype.toISOString
支持浏览器: chrome4 firefox3.6 safari4
https://bugs.webkit.org/show_bug.cgi?id=26594
String.prototype.trim
支持浏览器: chrome1+ firefox3+
https://bugs.webkit.org/show_bug.cgi?id=26590
http://code.google.com/p/v8/issues/detail?id=465
https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/String/Trim
“Array extras”
Array.prototype.{indexOf,lastIndexOf,every,some,forEach,map,filter,reduce,reduceRight}
IE8全部不支持,Opera不支持reduce,reduceRight,chrome与safari与firefox早就实现了
https://developer.mozilla.org/en/New_in_JavaScript_1.6#Array_extras
Array.isArray
支持浏览器: chrome4 opera10.50
http://codereview.chromium.org/271072
ECMAScript 5 Getters and Setters
这是旧有的javascript不能模拟的新特性!
o = { a:7, get b() { return this .a+1; }, set c(x) { this .a = x/2; } }; |
支持浏览器:Firefox 2.0+, Safari 3.0+, Chrome 1.0+, Opera 9.5+
非标准,Firefox1.5里的旧方法
HTMLElement.prototype.__defineGetter__( "innerHTML" , function () {}); HTMLElement.prototype.__defineSetter__( "innerHTML" , function (val) {}); |
支持浏览器:Firefox 2.0+, Safari 3.0+, Google Chrome 1.0+, Opera 9.5+
标准
Object.defineProperty(document.body, "innerHTML" , { get : function () {} }); MSDN文档:http: //msdn.microsoft.com/en-us/library/dd229916(VS.85).aspx |
支持:IE8+ (只能对DOM使用)
HTML5 DOM Storage
window.localStorage window.sessionStorage //可跨域,标签页关掉就清空 |
支持浏览器:Firefox 3.5+, Safari 4.0+, IE 8.0+
http://www.w3.org/TR/webstorage/
http://www.quirksmode.org/dom/html5.html#localstorage
https://developer.mozilla.org/en/DOM/Storage
http://msdn.microsoft.com/en-us/library/cc197062(VS.85).aspx
HTML5 Offline Application Cache
用一个manifest文件缓存静态资源(图片,css, js之类)在离线状态下使用,不是结构化数据
<html manifest= "foo.manifest" > <h1>Entry</h1> </html> |
支持浏览器:Firefox 3.5+
http://www.w3.org/TR/offline-webapps/#offline
https://developer.mozilla.org/en/Offline_resources_in_Firefox
HTML5 Web SQL Database Storage
//2007年就实现了! var database = openDatabase( "Database Name" , "Database Version" ); database.executeSql( "SELECT * FROM test" , function (result1) { // do something with the results database.executeSql( "DROP TABLE test" , function (result2) { // do some more stuff alert( "My second database query finished executing!" ); }); }); |
支持浏览器:Safari, iPhone OS 3, Opera 10.50,chrome4
http://webkit.org/blog/126/webkit-does-html5-client-side-database-storage/
http://www.weboshelp.net/getting-started-with-webos/156-palm-webos-html5-database-storage-tutorial/
HTML5 Web Workers
实现多线程!?
var worker = new Worker( "worker.js" ); // Watch for messages from the worker worker.onmessage = function (e){ // The message from the client: e.data }; worker.postMessage( "start" ); |
支持浏览器:firefox3.1+
https://developer.mozilla.org/En/Using_web_workers
HTML5 Geolocation
支持浏览器:FF3.5+, iPhone OS 3
http://www.w3.org/TR/geolocation-API/
https://developer.mozilla.org/En/Using_geolocation
HTML5 Drag and Drop
原生拖放API
支持浏览器:IE8, Safari 4, FF3.5
IE8如果报错,请刷新当前页面……
http://www.w3.org/TR/html5/editing.html#dnd
https://developer.mozilla.org/En/DragDrop/Drag_and_Drop
HTML5 Video
支持浏览器:Safari 4, FF3.5,chrome3+
https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox http://webkit.org/blog/140/html5-media-support/HTML5 audio
支持浏览器:Safari 4, FF3.5,chrome3+
HTML5 canvas
支持浏览器:IE以外所有新锐浏览器
https://developer.mozilla.org/en/Canvas_tutorial
HTML5 SVG
支持浏览器:Firefox 1.5+, Safari 3.0+, Chrome 1.0+, Opera 9.0+
http://www.ibm.com/developerworks/cn/views/xml/tutorials.jsp?cv_doc_id=84896
HTML5 XMLHttpRequest 2与跨域
支持浏览器:IE8与firefox3.5+各实现了部分
http://www.w3.org/TR/XMLHttpRequest2/
https://developer.mozilla.org/En/Using_XMLHttpRequest#Monitoring_progress
http://msdn.microsoft.com/en-us/library/cc197057(VS.85).aspx
https://developer.mozilla.org/En/HTTP_Access_Control
http://msdn.microsoft.com/en-us/library/cc197057(VS.85).aspx
HTML5的标签变更情况:
http://www.w3schools.com/html5/html5_reference.asp
上述特征的支持情况只对目前有效……
2012年1月16日,by司徒正美
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库