{"id":593,"date":"2008-10-11T11:10:10","date_gmt":"2008-10-11T03:10:10","guid":{"rendered":"http:\/\/fdream.net\/blog\/article\/593.aspx"},"modified":"2008-10-11T11:10:02","modified_gmt":"2008-10-11T03:10:02","slug":"%5b%e7%bf%bb%e8%af%91%5dIE+8+Beta+2%e4%b8%ad%e7%9a%84AJAX%e6%96%b0%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/fdream.net\/blog\/article\/593","title":{"rendered":"[\u7ffb\u8bd1]IE 8 Beta 2\u4e2d\u7684AJAX\u65b0\u529f\u80fd"},"content":{"rendered":"<h3>Updates for AJAX in IE8 Beta 2<\/h3>\n<h3>IE 8 Beta 2\u4e2d\u7684AJAX\u65b0\u529f\u80fd<\/h3>\n<p>\u539f\u6587\u5730\u5740\uff1ahttp:\/\/blogs.msdn.com\/ie\/archive\/2008\/10\/06\/updates-for-ajax-in-ie8-beta-2.aspx<\/p>\n<p>Sunava Dutta here, a program manager focused on improving AJAX in the browser! Now that Internet Explorer 8 Beta 2 is out, I want to write about some of the latest rounds of enhancements we\u2019ve made. As many of you may recall, back in March we discussed <a href=\"http:\/\/ajaxian.com\/archives\/ie-8-better-ajax-css-dom-and-new-features\" target=\"_blank\" title=\"a set of developer experiences\">a set of developer experiences<\/a> in AJAX across scenarios such as client-side cross-domain data access, local storage, and navigation state management among many others. The good news is our team has been working since Beta 1 to tweak and update our implementations based on feedback from developers (thanks for your contributions!) and ongoing updates to the W3C standards drafts on which most of these implementations are based or have been submitted for consideration. Not content with doing just that, we also added a few new features for developers. More on that later\u2026<\/p>\n<p>\u6211\u662fSunava Dutta\uff0c\u4e00\u4e2a\u81f4\u529b\u4e8e\u6539\u8fdb\u6d4f\u89c8\u5668\u91ccAJAX\u7684\u9879\u76ee\u7ecf\u7406\u3002\u73b0\u5728Internet Explorer 8 Beta 2\u5df2\u7ecf\u51fa\u6765\u4e86\uff0c\u6211\u60f3\u5199\u4e00\u4e9b\u5173\u4e8e\u6211\u4eec\u6700\u8fd1\u505a\u7684\u4e00\u4e9b\u6539\u8fdb\u3002\u53ef\u80fd\u8bb8\u591a\u4eba\u90fd\u8fd8\u8bb0\u5f97\uff0c\u65e9\u5728\u4e09\u6708\u4efd\u7684\u65f6\u5019\uff0c\u6211\u4eec\u8ba8\u8bba\u4e86\u4e00\u4e9b\u5217\u5173\u4e8e\u5728\u5404\u79cd\u573a\u666f\u4e0b\u7684<a href=\"http:\/\/ajaxian.com\/archives\/ie-8-better-ajax-css-dom-and-new-features\" target=\"_blank\" title=\"AJAX\u5f00\u53d1\u7ecf\u9a8c\">AJAX\u5f00\u53d1\u7ecf\u9a8c<\/a>\uff0c\u4f8b\u5982\u5ba2\u6237\u7aef\u8de8\u57df\u8bfb\u53d6\u6570\u636e\u3001\u672c\u5730\u5b58\u50a8\u4ee5\u53ca\u5bfc\u822a\u72b6\u6001\u7ba1\u7406\u7b49\u7b49\u3002\u597d\u6d88\u606f\u662f\u6211\u4eec\u7684\u56e2\u961f\u4eceBeta 1\u5f00\u59cb\uff0c\u5c31\u4e00\u76f4\u6839\u636e\u5f00\u53d1\u8005\u7684\u53cd\u9988\uff08\u8c22\u8c22\u4f60\u4eec\u7684\u8d21\u732e\uff01\uff09\u6765\u8c03\u6574\u548c\u66f4\u65b0\u6211\u4eec\u7684\u5b9e\u73b0\uff0c\u4e5f\u4e00\u76f4\u5728\u66f4\u65b0W3C\u6807\u51c6\u8349\u6848\uff0c\u5728\u8fd9\u5176\u4e2d\u7684\u8bb8\u591a\u5b9e\u73b0\u90fd\u662f\u57fa\u4e8e\u8fd9\u4e2a\u8349\u6848\u6216\u8005\u5df2\u7ecf\u63d0\u4ea4\u8fd9\u4e2a\u8349\u6848\u5ba1\u8bae\u7684\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u4e5f\u4e3a\u5f00\u53d1\u8005\u589e\u52a0\u4e86\u4e00\u4e9b\u65b0\u7684\u7279\u6027\uff0c\u8fd9\u4e2a\u4ee5\u540e\u518d\u8be6\u7ec6\u8bf4\u2026\u2026<\/p>\n<p>The AJAX updates we\u2019ve chosen for Beta 2 focus on maintaining cross-browser compatibility and the feature sets that developers have thought would be the most useful. Without further ado, here they are.<\/p>\n<p>\u5728Beta 2\u4e2d\u7684AJAX\u66f4\u65b0\u4e3b\u8981\u4fa7\u91cd\u4e8e\u7ef4\u62a4\u8de8\u6d4f\u89c8\u5668\u517c\u5bb9\u6027\u548c\u5f00\u53d1\u4eba\u5458\u8ba4\u4e3a\u6700\u6709\u7528\u7684\u4e00\u4e9b\u7279\u6027\u3002\u597d\u4e86\uff0c\u4e0d\u8bf4\u522b\u7684\u4e86\uff0c\u4e0b\u9762\u662f\u8fd9\u4e9b\u65b0\u7279\u6027\u3002<\/p>\n<p><b><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc288060(VS.85).aspx\" target=\"_blank\" title=\"XDomainRequest(XDR)\">XDomainRequest(XDR)<\/a><\/b><\/p>\n<p><b><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc288060(VS.85).aspx\" target=\"_blank\" title=\"XDomainRequest(XDR)\">XDomainRequest(XDR)<\/a><\/b><\/p>\n<p>This is an object built from the ground up to make client-side cross-domain calls secure and easy. To reduce the chances of inadvertent cross domain access, this object requires an explicit acknowledgement for allowing cross domain calls from the client script and the server. Additionally, it reduces the need for sites having to resort to the dangerous practice of merge scripting from third parties directly into the mashup page. This practice is dangerous because it provides third parties full access to the DOM. All this comes with the added benefit of improved client-side performance and lower server maintenance costs thanks to the absence of a need for server farms for proxying.<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u5728\u5e95\u5c42\u6784\u5efa\u7684\u5bf9\u8c61\uff08object\uff09\uff0c\u53ef\u4ee5\u8ba9\u5ba2\u6237\u7aef\u8de8\u57df\u8bf7\u6c42\u5f88\u5b89\u5168\u548c\u5bb9\u6613\u3002\u4e3a\u4e86\u51cf\u5c11\u610f\u5916\u7684\u60c5\u51b5\u4e0b\u7684\u8de8\u57df\u8bf7\u6c42\uff0c\u8fd9\u4e2a\u5bf9\u8c61\u9700\u8981\u4ece\u53d1\u51fa\u8bf7\u6c42\u7684\u5ba2\u6237\u7aef\u811a\u672c\u548c\u670d\u52a1\u5668\u5f97\u5230\u4e00\u4e2a\u660e\u786e\u7684\u786e\u8ba4\uff0c\u4ee5\u786e\u8ba4\u8fd9\u4e2a\u8de8\u57df\u8bf7\u6c42\u3002\u6b64\u5916\uff0c\u8fd9\u51cf\u5c11\u4e86\u7f51\u7ad9\u9875\u9762\u4e2d\u7531\u4e8e\u7b2c\u4e09\u65b9\u5408\u5e76\u811a\u672c\u5e26\u6765\u7684\u98ce\u9669\u9700\u6c42\u3002\u8fd9\u79cd\u505a\u6cd5\u4e4b\u6240\u4ee5\u662f\u5371\u9669\u7684\uff0c\u662f\u56e0\u4e3a\u5b83\u7ed9\u7b2c\u4e09\u65b9\u63d0\u4f9b\u4e86\u5b8c\u5168\u7684DOM\u63a7\u5236\u6743\u3002\u8fd9\u4e00\u5207\u90fd\u8ddf\u968f\u7740\u6539\u8fdb\u7684\u5ba2\u6237\u7aef\u8868\u73b0\u5e26\u6765\u7684\u597d\u5904\u548c\u56e0\u4e3a\u4e0d\u9700\u8981\u4ee3\u7406\u670d\u52a1\u5668\u7fa4\u800c\u5e26\u6765\u7684\u66f4\u4f4e\u7684\u670d\u52a1\u5668\u7ef4\u62a4\u6210\u672c\u3002<\/p>\n<p>During the Beta 1 timeframe there were many security based concerns raised for cross domain access of third party data using <a href=\"http:\/\/www.w3.org\/TR\/XMLHttpRequest2\/\" target=\"_blank\" title=\"cross site XMLHttpRequest\">cross site XMLHttpRequest<\/a> and the Access Control framework. Since Beta 1, we had the chance to work with other browsers and attendees at a W3C face-to-face meeting to improve the server-side experience and security of the W3C\u2019s Access Control framework. As a result, we\u2019ve updated XDR to be explicitly compliant with syntax and directives in the sections of Access Control for requesting simple public third-party data anonymously on the client! (Section <a href=\"http:\/\/dev.w3.org\/2006\/waf\/access-control\/#simple\" target=\"_blank\" title=\"5.1.3 in the Access Control Process Model\">5.1.3 in the Access Control Process Model<\/a>)<\/p>\n<p>\u5728Beta 1\u7684\u65f6\u95f4\u8868\u4e2d\uff0c\u4e3a\u8de8\u57df\u8bf7\u6c42\u7b2c\u4e09\u65b9\u6570\u636e\u63d0\u51fa\u4e86\u8bb8\u591a\u57fa\u4e8e\u5b89\u5168\u7684\u8003\u8651\uff0c\u8fd9\u4e9b\u8de8\u57df\u8bf7\u6c42\u4f7f\u7528\u4e86<a href=\"http:\/\/www.w3.org\/TR\/XMLHttpRequest2\/\" target=\"_blank\" title=\"\u8de8\u7f51\u7ad9\u7684XMLHttpRequest\">\u8de8\u7f51\u7ad9\u7684XMLHttpRequest<\/a>\u548c\u5b58\u53d6\u63a7\u4ef6\u6846\u67b6\u3002\u81ea\u4eceBeta 1\u5f00\u59cb\uff0c\u6211\u4eec\u6709\u673a\u4f1a\u548c\u5176\u4ed6\u7684\u6d4f\u89c8\u5668\u53ca\u5176\u4ed6W3C\u4e0e\u4f1a\u8005\u8fdb\u884c\u9762\u5bf9\u9762\u4f1a\u8bae\uff0c\u8ba8\u8bba\u5982\u4f55\u6539\u8fdb\u670d\u52a1\u5668\u7aef\u7684\u4f53\u9a8c\u4ee5\u53caW3C\u7684\u5b58\u53d6\u63a7\u4ef6\u6846\u67b6\u7684\u5b89\u5168\u6027\u3002\u5728\u6700\u540e\uff0c\u6211\u4eec\u66f4\u65b0\u4e86XDR\uff0c\u8ba9\u5176\u4e25\u683c\u9075\u5faa\u5b58\u53d6\u63a7\u5236\u7ae0\u8282\u4e2d\u5173\u4e8e\u5728\u5ba2\u6237\u7aef\u533f\u540d\u8bf7\u6c42\u7b80\u5355\u516c\u5f00\u7684\u7b2c\u4e09\u65b9\u6570\u636e\u7684\u8bed\u6cd5\u548c\u6307\u4ee4\u89c4\u5219\uff01\uff08<a href=\"http:\/\/dev.w3.org\/2006\/waf\/access-control\/#simple\" target=\"_blank\" title=\"\u5b58\u53d6\u63a7\u5236\u5904\u7406\u6a21\u578b\u7b2c5.1.3\u8282\">\u5b58\u53d6\u63a7\u5236\u5904\u7406\u6a21\u578b\u7b2c5.1.3\u8282<\/a>\uff09<\/p>\n<p>The updates to XDR from Beta 1 allow IE8 to request data from the domain&#8217;s server by sending an Origin header with the serialized value of the origin of the requestor. IE8 Beta 2 will only return the response if the server responds with Access-Control-Allow-Origin: *, instead of allowing the XDomainRequestAllowed: 1 header as we did in Beta 1. Other changes include support for relative paths in the open method, and restricting access to only HTTP and HTTPS destinations.<\/p>\n<p>\u4eceBeta 1\u5f00\u59cb\uff0c\u66f4\u65b0\u540e\u7684XDR\u5141\u8bb8IE 8\u4ece\u6307\u5b9a\u57df\u7684\u670d\u52a1\u5668\u8bf7\u6c42\u6570\u636e\uff0c\u5728\u53d1\u51fa\u8bf7\u6c42\u65f6\u5fc5\u987b\u53d1\u9001\u5e8f\u5217\u5316\u540e\u7684\u539f\u59cb\u8bf7\u6c42\u7684\u5934\u90e8\u503c\u3002\u5982\u679c\u670d\u52a1\u5668\u54cd\u5e94\u4e3a\uff1aAccess-Control-Allow-Origin:*\uff0cIE8 Beta 2\u5c06\u53ea\u8fd4\u56de\u54cd\u5e94\uff0c\u6211\u4eec\u5728Beta 1\u4e2d\u505a\u4e86\u4e00\u4e2a\u5934\u90e8\u7528\u6765\u4ee3\u66ff\u5141\u8bb8XDomainRequestAllowed\u3002\u5176\u4ed6\u7684\u53d8\u5316\u5305\u62ec\u652f\u6301\u76f8\u5bf9\u8def\u5f84\u7684\u5f00\u653e\u65b9\u6cd5\u548c\u4e25\u683c\u7684HTTP\u548cHTTPS\u76ee\u7684\u5730\u8bf7\u6c42\u63a7\u5236\u3002<\/p>\n<p><b><a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=128221\" target=\"_blank\" title=\"Cross-document Messaging(XDM)\">Cross-document Messaging(XDM)<\/a><\/b><\/p>\n<p><b><a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=128221\" target=\"_blank\" title=\"\u8de8\u6587\u6863\u6d88\u606f(XDM)\">\u8de8\u6587\u6863\u6d88\u606f(XDM)<\/a><\/b><\/p>\n<p><a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=128221\" target=\"_blank\" title=\"Cross-document messaging\">Cross-document messaging<\/a> is another powerful cross-domain feature that <a href=\"http:\/\/blogs.msdn.com\/ie\/archive\/2008\/05\/19\/enabling-mash-ups-in-internet-explorer-8-with-cross-document-messaging.aspx\" target=\"_blank\" title=\"I\u2019ve blogged about in the past\">I\u2019ve blogged about in the past<\/a>. Rather than make a backend request to a remote Web service, this allows sites hosting third-party IFrame-based &#8220;gadgets&#8221; or components to communicate directly with the parent, without unsafely violating the same site origin policy. This has advantages including improved performance and reliability, as developers don\u2019t have to resort to workarounds that behave differently between browsers and have unwanted side-effects. This technique also removes the need for embedding third-party script in your page, lessening the chance of potential information disclosure vulnerabilities like the disclosure of your sensitive data (such as information in your social network profile) to third parties without your consent.<\/p>\n<p><a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=128221\" target=\"_blank\" title=\"\u8de8\u6587\u6863\u6d88\u606f\">\u8de8\u6587\u6863\u6d88\u606f<\/a>\u662f<a href=\"http:\/\/blogs.msdn.com\/ie\/archive\/2008\/05\/19\/enabling-mash-ups-in-internet-explorer-8-with-cross-document-messaging.aspx\" target=\"_blank\" title=\"\u6211\u66fe\u7ecf\u5728blog\u4e2d\u63d0\u5230\u8fc7\u7684\">\u6211\u66fe\u7ecf\u5728blog\u4e2d\u63d0\u5230\u8fc7\u7684<\/a>\u4e00\u4e2a\u5f3a\u5927\u7684\u8de8\u57df\u7279\u6027\u3002\u5b83\u5141\u8bb8\u7f51\u7ad9\u4f7f\u7528\u7b2c\u4e09\u65b9\u7684\u57fa\u4e8eIFrame\u7684\u201c\u5c0f\u5de5\u5177\uff08gadgets\uff09\u201d\u6216\u8005\u9010\u6e10\u76f4\u63a5\u4e0e\u7236\uff08parent\uff09\u9875\u9762\u4ea4\u4e92\uff0c\u800c\u4e0d\u662f\u53d1\u9001\u4e00\u4e2a\u540e\u7aef\u8bf7\u6c42\u5230\u8fdc\u7a0bWeb\u670d\u52a1\uff0c\u800c\u4e0d\u662f\u975e\u5b89\u5168\u5730\u8fdd\u53cd\u540c\u4e00\u4e2a\u7f51\u7ad9\u7684\u6e90\u7b56\u7565\u3002\u8fd9\u9879\u529f\u80fd\u80fd\u591f\u6539\u8fdb\u6027\u80fd\u548c\u53ef\u9760\u6027\uff0c\u56e0\u4e3a\u5f00\u53d1\u8005\u4e0d\u7528\u518d\u53bb\u4e3a\u4e0d\u540c\u6d4f\u89c8\u5668\u7684\u4e0d\u540c\u884c\u4e3a\u548c\u4e0d\u60f3\u8981\u7684\u6548\u679c\u800c\u56f0\u6270\u3002\u8fd9\u4e2a\u6280\u672f\u4e5f\u4e0d\u5728\u9700\u8981\u5728\u4f60\u7684\u9875\u9762\u4e2d\u5d4c\u5165\u7b2c\u4e09\u65b9\u7684\u811a\u672c\uff0c\u51cf\u5c11\u4e86\u6f5c\u5728\u7684\u4fe1\u606f\u6cc4\u9732\u7684\u98ce\u9669\uff0c\u4f8b\u5982\u5728\u4e3a\u5f97\u5230\u4f60\u7684\u5141\u8bb8\u7684\u60c5\u51b5\u4e0b\u6cc4\u9732\u4f60\u7684\u654f\u611f\u6570\u636e\uff08\u6bd4\u5982\u4f60\u7684\u793e\u4f1a\u6027\u7f51\u7edc\u8d44\u6599\uff09\u7ed9\u7b2c\u4e09\u65b9\u3002<\/p>\n<p>Beta 2 updates here include moving the onmessage handler from the document object to the window object to better align with the updated HTML 5.0 draft.<\/p>\n<p>\u8fd9\u91ccBeta 2\u7684\u66f4\u65b0\u5305\u62ec\u628aonmessage\u7684handler\u4ece\u6587\u6863\u5bf9\u8c61\uff08the document object\uff09\u4e2d\u79fb\u52a8\u5230\u4e86window\u5bf9\u8c61\u4e2d\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u4e0e\u66f4\u65b0\u540e\u7684HTML 5.0\u8349\u6848\u4e00\u81f4\u3002<\/p>\n<p><pre lang=\"javascript\">\nwindow.attachEvent(&quot;onmessage&quot;, HandleMessage);\n<\/pre>\n<\/p>\n<p>We also replaced e.URI with e.origin, which is serialized form of \u201cscheme\u201d + \u201chost\u201d + \u201cnon-default port\u201d. This is far safer as the URI can carry potentially sensitive information from the origin site that is not needed by the recipient for the decision to grant or not grant access.<\/p>\n<p>\u6211\u4eec\u8fd8\u7528e.origin\u6765\u66ff\u4ee3\u4e86e.URI\uff0ce.origin\u662f\u5f62\u5982\u201cscheme\u201d + \u201chost\u201d + \u201cnon-default port\u201d\u5e8f\u5217\u5316\u7ec4\u5408\u3002\u8fd9\u4e2a\u80fd\u66f4\u5b89\u5168\u5730\u51b3\u5b9a\u6388\u6743\u6216\u8005\u4e0d\u6388\u6743\uff0c\u56e0\u4e3aURI\u80fd\u591f\u4ece\u6e90\u7ad9\u643a\u5e26\u63a5\u53d7\u8005\u4e0d\u9700\u8981\u7684\u6f5c\u5728\u654f\u611f\u4fe1\u606f\u3002<\/p>\n<p><pre lang=\"javascript\">\nif (e.origin == 'http:\/\/www.contoso.com')  \n{  \n    \/\/ process message text      \n}\n<\/pre>\n<\/p>\n<p>Finally, the HTML 5.0 draft also mandates that the targetOrigin parameter for the postMessage method now be made a required parameter, as opposed to an optional one. This will make it difficult for developers to make errors by requiring an explicit acknowledgement of the target destination of the message by specifying the origin <URL> or wildcard <*>.<\/p>\n<p>\u6700\u540e\uff0cHTML 5.0\u8349\u6848\u8fd8\u89c4\u5b9a\uff0cpostMessage\u65b9\u6cd5\u7684targetOrigin\u53c2\u6570\u662f\u5fc5\u987b\u53c2\u6570\uff0c\u800c\u4e0d\u662f\u53ef\u9009\u53c2\u6570\u3002\u8fd9\u5c06\u8ba9\u5f00\u53d1\u8005\u4e0d\u518d\u56e0\u4e3a\u9700\u8981\u4e25\u683c\u786e\u8ba4\u800c\u5bb9\u6613\u72af\u9519\uff0c\u56e0\u4e3a\u4e0d\u77e5\u9053\u76ee\u6807\u6e90\u6d88\u606f\u662f\u8981\u6307\u5b9a\u6307\u5b9a\u6e90<URL>\u8fd8\u662f\u901a\u914d\u7b26<*>\u3002<\/p>\n<p><pre lang=\"javascript\">\nframeOther.postMessage(&quot;This is a message&quot;, &quot;http:\/\/example.com&quot;);\n<\/pre>\n<\/p>\n<p><b>DOM Storage<\/b><\/p>\n<p><b>DOM\u5b58\u50a8<\/b><\/p>\n<p>Today, web pages use the document.cookie property to store data on the local machine. Cookies are limited in capability by the fact that sites can only store 50 key\/value pairs per domain. Furthermore, the cookie programming model is cumbersome and requires parsing the entire cookie string for data. While cookies are useful for marking transitions and changes on the client to the server as they are sent with the request headers in chunks of up to 4KB, IE8 brings better alternatives for scenarios involving persisting data on the client and distinctly maintaining sessions in different tabs. The W3C\u2019s HTML 5 DOM Storage objects provide a much simpler global and session storage model for key\/value pair string data. Sites can store data for the life of a tab or until the site or user clears the data.<\/p>\n<p>\u73b0\u5728\uff0c\u7f51\u9875\u4f7f\u7528document.cookie\u5c5e\u6027\u6765\u5b58\u50a8\u6570\u636e\u5230\u672c\u5730\u3002Cookies\u5b9e\u9645\u5b58\u50a8\u80fd\u529b\u662f\u6709\u9650\u7684\uff0c\u4e00\u4e2a\u7f51\u7ad9\u57df\u540d\u53ea\u80fd\u5b58\u50a850\u4e2a\u952e\u503c\u5bf9\uff08key\/value pair\uff09\u3002\u6b64\u5916\uff0ccookie\u7f16\u7a0b\u6a21\u578b\u5f88\u4e0d\u7075\u6d3b\uff0c\u9700\u8981\u628a\u6574\u4e2acookie\u5b57\u7b26\u4e32\u89e3\u6790\u6210\u6570\u636e\u3002\u56e0\u4e3acookie\u5bf9\u4e8e\u5ba2\u6237\u7aef\u5230\u670d\u52a1\u5668\u7aef\u7684\u8fc7\u6e21\u548c\u53d8\u5316\u975e\u5e38\u6709\u7528\uff0c\u56e0\u4e3a\u5b83\u4eec\u662f\u5728\u8bf7\u6c42\u5934\u90e8\u4e2d\u53d1\u9001\u7684\uff0c\u6700\u9ad8\u53ef\u4ee5\u8fbe\u52304KB\uff0cIE8\u5e26\u6765\u4e86\u66f4\u597d\u7684\u66ff\u4ee3\u65b9\u6848\u5728\u4e0d\u540c\u7684\u573a\u666f\u4e2d\u4f7f\u7528\uff0c\u5305\u62ec\u5728\u5ba2\u6237\u7aef\u4fdd\u5b58\u6570\u636e\u548c\u7ef4\u62a4\u4e0d\u540c\u6807\u7b7e\u9875\uff08tabs\uff09\u4e4b\u95f4\u7684\u4f1a\u8bdd\uff08sessions\uff09\u3002W3C\u7684HTML 5 DOM\u5b58\u50a8\u5bf9\u8c61\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u5f97\u591a\u7684\u5168\u5c40\u548c\u4f1a\u8bdd\uff08session\uff09\u952e\u503c\u5bf9\uff08key\/value pair\uff09\u5b57\u7b26\u4e32\u6570\u636e\u5b58\u50a8\u6a21\u578b\u3002\u7f51\u7ad9\u80fd\u591f\u5728\u4e00\u4e2a\u6807\u7b7e\u9875\uff08tab\uff09\u7684\u751f\u5b58\u5468\u671f\u5185\u5b58\u50a8\u6570\u636e\u6216\u8005\u76f4\u5230\u7f51\u7ad9\u6216\u8005\u7528\u6237\u6e05\u9664\u6570\u636e\u4e3a\u6b62\u3002<\/p>\n<p>Updates for Beta 2 include changing the name of the persistent globalStorage attribute to localStorage and the removal of the need to specify the domain when writing to the localStorage<\/p>\n<p>Beta 2\u7684\u66f4\u65b0\u5305\u62ec\uff1a\u66f4\u6539\u4e86globalStorage\u5c5e\u6027\u540d\u5b57\u4e3alocalStorage\uff0c\u5e76\u53bb\u6389\u4e86\u5199\u6570\u636e\u65f6\u5fc5\u987b\u6307\u5b9a\u57df\uff08domain\uff09\u7684\u9700\u8981\u3002<\/p>\n<p><pre lang=\"javascript\">\n\/\/ Store a key-value pair. \nlocalStorage.setItem(&quot;FirstName&quot;,&quot;Sunava&quot;);\n<\/pre>\n<\/p>\n<p>Finally, we also included improved support of the updated onstorage HTML 5.0 event returned when the storage is changed. We now return the URI when the local storage is changed, so that handlers for pages can know who carried out the latest transaction in the storage space in addition to providing the source to the window of the origin. Furthering the good news, the HTML 5.0 Working Group has incorporated the clear method, which we shipped in Beta 1, into the draft. This essentially allows for script to clear all items accessible in its storage space without having to iterate though the keys.<\/p>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u4e5f\u6539\u5584\u4e86\u652f\u6301\u5728HTML 5.0\u7684onstorage\u4e8b\u4ef6\uff08\u5f53storage\u6539\u53d8\u65f6\uff09\u8fd4\u56de\u65f6\u66f4\u65b0\u3002\u5f53\u672c\u5730\u5b58\u50a8\u6539\u53d8\u65f6\uff0c\u6211\u4eec\u8fd4\u56de\u8fd9\u4e2aURI\uff0c\u9875\u9762\u4e2d\u7684\u5904\u7406\u7a0b\u5e8f\u5c31\u53ef\u4ee5\u77e5\u9053\u8c01\u5728\u5b58\u50a8\u7a7a\u95f4\u4e2d\u505a\u4e86\u6700\u65b0\u7684\u6539\u53d8\uff0c\u4ece\u800c\u5c31\u53ef\u4ee5\u628a\u8fd9\u4e2a\u6e90\u63d0\u4f9b\u7ed9\u539f\u59cb\u7684\u7a97\u53e3\uff08window\uff09\u3002\u66f4\u597d\u7684\u6d88\u606f\u662f\uff0cHTML 5.0\u5de5\u4f5c\u5c0f\u7ec4\u5df2\u7ecf\u5c06\u6211\u4eec\u5728Beta 1\u4e2d\u4f7f\u7528\u7684\u6e05\u9664\u65b9\u6cd5\u7eb3\u5165\u4e86\u8349\u6848\u3002\u8fd9\u4ece\u6839\u672c\u4e0a\u5141\u8bb8\u4e86\u811a\u672c\u6765\u6e05\u7406\u5b83\u5b58\u50a8\u7a7a\u95f4\u4e2d\u7684\u9879\u76ee\uff0c\u800c\u4e0d\u9700\u8981\u4e00\u4e2a\u4e00\u4e2a\u679a\u4e3e\u904d\u5386\u3002<\/p>\n<p><b>Connectivity Event<\/b><\/p>\n<p><b>\u8fde\u901a\u6027\u4e8b\u4ef6<\/b><\/p>\n<p>The <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc304129(VS.85).aspx\" target=\"_blank\" title=\"<b>navigator.onLine<\/b> property and online\/offline events&#8221;><b>navigator.onLine<\/b> property and online\/offline events<\/a> now work on Windows XP as well as Windows Vista. The work to enable this was not trivial, as connection awareness in Windows XP is not quite as advanced as Windows Vista. That said, this will be extremely beneficial for developers, who we believe shouldn\u2019t have to worry about OS differences. The value of connectivity events is particularly appealing when used in conjunction with the localstorage, where data can be cached in case of network loss!<\/p>\n<p>\u5728Windows XP\u4e0a\uff0c<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc304129(VS.85).aspx\" target=\"_blank\" title=\"<b>navigator.onLine<\/b>\u5c5e\u6027\u548conline\/offline\u4e8b\u4ef6&#8221;><b>navigator.onLine<\/b>\u5c5e\u6027\u548conline\/offline\u4e8b\u4ef6<\/a>\u73b0\u5728\u80fd\u591f\u50cf\u5728Windows Vista\u4e0a\u4e00\u6837\u5de5\u4f5c\u4e86\u3002\u542f\u52a8\u8fd9\u4e2a\u5e76\u4e0d\u662f\u6ca1\u6709\u610f\u4e49\u7684\uff0c\u56e0\u4e3a\u8fde\u63a5\u611f\u77e5\uff08connection awareness\uff09\u5728Windows XP\u4e0a\u5e76\u6ca1\u6709\u50cfWindows Vista\u4e0a\u90a3\u4e48\u5b8c\u5584\u3002\u8fd9\u610f\u5473\u7740\uff0c\u8fd9\u5c06\u4f7f\u5f00\u53d1\u8005\u6781\u5ea6\u53d7\u76ca\uff0c\u6211\u4eec\u76f8\u4fe1\u4ed6\u4eec\u4e0d\u518d\u56e0\u4e3a\u64cd\u4f5c\u7cfb\u7edf\u4e0d\u540c\u800c\u7740\u6025\u4e86\u3002\u5728\u8fdb\u884c\u672c\u5730\u5b58\u50a8\u65f6\uff0c\u8fde\u901a\u6027\u4e8b\u4ef6\u7684\u4ef7\u503c\u662f\u975e\u5e38\u6709\u5438\u5f15\u529b\u7684\u2014\u2014\u5f53\u8fde\u63a5\u65ad\u5f00\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u7f13\u5b58\u6570\u636e\uff01<\/p>\n<p><b>XMLHttpRequest<\/b><\/p>\n<p><b>XMLHttpRequest<\/b><\/p>\n<p>Introducing the XDomainRequest object in IE8 hasn\u2019t diverted our attentions from constantly tweaking and improving XMLHttpRequest, which will continue to be our flagship object for same-domain communications. Post-Beta 1 energies here have focused on a few bug fixes around reliability and working with the Web Apps Working Group to clarify and improve the draft specification, our compliance with it, and W3C public test cases. A <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc534581(VS.85).aspx\" target=\"_blank\" title=\"timeout method\">timeout method<\/a> introduced here in Beta 1 for the convenience of developers is currently being evaluated for adoption in the XMLHttpRequest spec.<\/p>\n<p>\u5728\u4ecb\u7ecdXDomainRequest\u5bf9\u8c61\u65f6\uff0c\u6211\u4eec\u6ca1\u6709\u63d0\u5230\u6211\u4eec\u4e00\u76f4\u5728\u575a\u6301\u4e0d\u61c8\u5730\u8c03\u6574\u548c\u6539\u8fdbXMLHttpRequest\u2014\u2014\u8fd9\u4ecd\u7136\u662f\u6211\u4eec\u540c\u57df\u901a\u4fe1\u7684\u65d7\u8230\u5bf9\u8c61\u3002Beta 1\u7684\u540e\u671f\u7cbe\u529b\u4e3b\u8981\u96c6\u4e2d\u5728\u4fee\u590d\u4e00\u4e9b\u5173\u4e8e\u53ef\u9760\u6027\u7684\u7f3a\u9677\uff08bug\uff09\uff0c\u4ee5\u53ca\u4e0eWeb\u5e94\u7528\u5de5\u4f5c\u7ec4\uff08Web Apps Working Group \uff09\u4e00\u8d77\u5de5\u4f5c\uff0c\u4ee5\u660e\u786e\u548c\u6539\u8fdb\u8349\u6848\uff0c\u6211\u4eec\u9075\u4ece\u8349\u6848\uff0cW3C\u516c\u5f00\u6d4b\u8bd5\u6848\u4f8b\u3002\u8fd9\u91cc\u4ecb\u7ecd\u4e00\u4e2a\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u66f4\u65b9\u4fbf\u7684<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc534581(VS.85).aspx\" target=\"_blank\" title=\"\u8d85\u65f6\uff08timeout\uff09\u65b9\u6cd5\">\u8d85\u65f6\uff08timeout\uff09\u65b9\u6cd5<\/a>\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u6b63\u5728\u88ab\u8bc4\u4f30\u4ee5\u7eb3\u5165XMLHttpRequest\u89c4\u8303\u3002<\/p>\n<p><pre lang=\"javascript\">\n\/\/ Sets timeout after open to two seconds. \nxhr.timeout = 2000;\n<\/pre>\n<\/p>\n<p><b>ToStaticHTML, to JSON, and fromJSON<\/b><\/p>\n<p><b>ToStaticHTML, to JSON, and fromJSON<\/b><\/p>\n<p>What do you do with the strings returned from third parties using XDomainRequest or Cross-document Messaging? In today\u2019s world of increasing script injection and Cross-site Scripting (XSS) attacks, having the option of passing these through a safe parser comes as a welcome relief. As detailed in Eric Lawrence&#8217;s post on <a href=\"http:\/\/blogs.msdn.com\/ie\/archive\/2008\/07\/02\/ie8-security-part-v-comprehensive-protection.aspx\" target=\"_blank\" title=\"Comprehensive Protection\">Comprehensive Protection<\/a> for IE8 Security, <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc848922(VS.85).aspx\" target=\"_blank\" title=\"toStaticHTML\">toStaticHTML<\/a> provides a powerful way of sanitizing your strings by purging potentially executable content.<\/p>\n<p>\u5f53\u7b2c\u4e09\u65b9\u4f7f\u7528XDomainRequest\u6216\u8005\u8de8\u6587\u6863\u6d88\u606f\uff08Cross-document Messaging\uff09\u8fd4\u56de\u5b57\u7b26\u4e32\u65f6\uff0c\u4f60\u600e\u4e48\u529e\uff1f\u5728\u73b0\u5728\u811a\u672c\u6ce8\u5165\u548c\u5938\u7ad9\u811a\u672c\u653b\u51fb\u4e0d\u65ad\u589e\u52a0\u7684\u4e16\u754c\u4e2d\uff0c\u6709\u4e00\u4e2a\u5b89\u5168\u5730\u89e3\u6790\u8fd9\u4e9b\u5b57\u7b26\u4e32\u7684\u9009\u62e9\u5c06\u4f1a\u662f\u975e\u5e38\u53d7\u6b22\u8fce\u7684\u3002\u5c31\u50cfEric Lawrence\u5728\u4ed6\u7684\u5173\u4e8e\u300a<a href=\"http:\/\/blogs.msdn.com\/ie\/archive\/2008\/07\/02\/ie8-security-part-v-comprehensive-protection.aspx\" target=\"_blank\" title=\"IE8\u5b89\u5168\u7684\u5168\u9762\u4fdd\u62a4\">IE8\u5b89\u5168\u7684\u5168\u9762\u4fdd\u62a4<\/a>\u300b\u7684\u6587\u7ae0\u4e2d\u63d0\u5230\u7684\u4e00\u6837\uff0c<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc848922(VS.85).aspx\" target=\"_blank\" title=\"toStaticHTML\">toStaticHTML<\/a>\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f3a\u5927\u7684\u65b9\u5f0f\u6765\u8fc7\u6ee4\u4f60\u7684\u5b57\u7b26\u4e32\u4ee5\u6e05\u9664\u6f5c\u5728\u7684\u53ef\u6267\u884c\u7684\u5185\u5bb9\u3002<\/p>\n<p><pre lang=\"javascript\">\n\/\/Calling: \nwindow.toStaticHTML(&quot;This is some &lt;b&gt;HTML&lt;\/b&gt; with embedded script following... &lt;script&gt;alert('bang!');&lt;\/script&gt;!&quot;);\n\n\/\/will return: \nThis is some &lt;b&gt;HTML&lt;\/b&gt; with embedded script following... !\n<\/pre>\n<\/p>\n<p>In addition, IE8 Beta 2\u2019s <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc836458(VS.85).aspx\" target=\"_blank\" title=\"JSON.stringify and JSON.parse\">JSON.stringify and JSON.parse<\/a> methods provide improved performance as opposed to non-native Javascript serializers and deserializers. Our implementation is based on the ECMAScript 3.1 proposal for native JSON-handling which uses Douglas Crockford\u2019s <a href=\"http:\/\/www.json.org\/json2.js\" target=\"_blank\" title=\"json2.js\">json2.js<\/a> API. In addition to the performance benefits of going native, the JSON parser provides a safe alternative to the eval() method, which has been a common and dangerous way to revive JSON objects, and could allow arbitrary script functions to execute.<\/p>\n<p>\u6b64\u5916\uff0cIE8 Beta 2\u7684<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc836458(VS.85).aspx\" target=\"_blank\" title=\"JSON.stringify\u548cJSON.parse\">JSON.stringify\u548cJSON.parse<\/a>\u65b9\u6cd5\u7684\u63d0\u4f9b\u4e86\u6539\u8fdb\u7684\u6027\u80fd\uff0c\u4ee5\u9488\u5bf9\u975e\u672c\u5730JavaScript\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u3002\u6211\u7684\u5b9e\u73b0\u662f\u57fa\u4e8eECMAScript 3.1\u5173\u4e8e\u672c\u5730JSON\u5904\u7406\uff08JSON-handling\uff09\u7684\u5efa\u8bae\u2014\u2014\u4f7f\u7528Douglas Crockford\u7684<a href=\"http:\/\/www.json.org\/json2.js\" target=\"_blank\" title=\"json2.js\">json2.js<\/a> API\u3002\u51fa\u4e86\u80fd\u5f97\u5230\u672c\u5730\u5316\u7684\u6027\u80fd\u597d\u5904\u4e4b\u5916\uff0cJSON\u89e3\u6790\u5668\u63d0\u4f9b\u4e86\u6bd4eval()\u65b9\u6cd5\u66f4\u5b89\u5168\u7684\u66ff\u4ee3\u65b9\u6cd5\uff0ceva()\u65b9\u6cd5\u662f\u5904\u7406JSON\u5bf9\u8c61\u4e2d\u5e38\u7528\u7684\u548c\u5371\u9669\u7684\u65b9\u6cd5\uff0c\u5b83\u5141\u8bb8\u6267\u884c\u4efb\u610f\u811a\u672c\u529f\u80fd\u3002<\/p>\n<p><b>Other Features<\/b><\/p>\n<p><b>\u5176\u4ed6\u7279\u6027<\/b><\/p>\n<p>AJAX Navigations has undergone minimal changes since Beta 1. We\u2019ve got some new code samples and overview documentation on this for Beta 2 on <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc891506(VS.85).aspx\" target=\"_blank\" title=\"MSDN\">MSDN<\/a>. Improved <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc304129(VS.85).aspx#concurrent_connections\" target=\"_blank\" title=\"connection parallelism\">connection parallelism<\/a> per host has also undergone a few tweaks and will command its own post soon.<\/p>\n<p>\u81eaBeta 1\u4ee5\u6765\uff0cAJAX\u5bfc\u822a\u7ecf\u5386\u4e86\u5f88\u5c0f\u7684\u6539\u53d8\u3002\u5728<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc891506(VS.85).aspx\" target=\"_blank\" title=\"MSDN\">MSDN<\/a>\u4e0a\uff0c\u6211\u4eec\u6709\u4e86\u4e00\u4e9b\u5173\u4e8eBeta 2\u7248\u672c\u7684\u8fd9\u4e9b\u65b0\u7279\u6027\u90a3\u4e2a\u7684\u65b0\u7684\u4ee3\u7801\u793a\u4f8b\u548c\u6982\u8981\u6587\u6863\u3002\u6bcf\u4e2a\u4e3b\u673a\u7684<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc304129(VS.85).aspx#concurrent_connections\" target=\"_blank\" title=\"\u5e76\u53d1\u94fe\u63a5\">\u5e76\u53d1\u94fe\u63a5<\/a>\u4e5f\u505a\u4e86\u4e00\u4e9b\u8c03\u6574\u548c\u6539\u8fdb\uff0c\u76f8\u5173\u6587\u6863\u4e5f\u5373\u5c06\u51fa\u6765\u3002<\/p>\n<p><b>Summary<\/b><\/p>\n<p><b>\u603b\u7ed3<\/b><\/p>\n<p>We\u2019ve worked in standards to make the AJAX experience for developers better. Beta 2 implements the changes mentioned above. Moving forward, we will continue to partner with members in the W3C on a variety of topics including advancing draft specifications. Strong developer adoption of these features is a priority and we\u2019re focusing on help sites transition to integrating these features. For code samples for the AJAX feature set, please refer to our IE8 AJAX Beta 2 <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=128984\" target=\"_blank\" title=\"Hands on Labs\">Hands on Labs<\/a>. In case you\u2019ve wondered who the \u2018we\u2019 in the AJAX core development team is, below is a photo (unedited, red eyes included) that puts a few faces to the names that pop up occasionally on blogs and mailing lists! Enjoy!<\/p>\n<p>\u8ba9\u5f00\u53d1\u8005\u7684AJAX\u4f53\u9a8c\u66f4\u597d\uff0c\u8fd9\u662f\u6211\u4eec\u5de5\u4f5c\u7684\u76ee\u6807\u3002Beta 2\u7248\u672c\u5b9e\u73b0\u4e86\u8fd9\u4e0a\u9762\u6240\u6709\u63d0\u5230\u7684\u6539\u53d8\u3002\u5728\u7ee7\u7eed\u5411\u524d\u7684\u8def\u4e0a\uff0c\u6211\u4eec\u5c06\u7ee7\u7eed\u548cW3C\u7684\u6210\u5458\u5728\u8bb8\u591a\u4e3b\u9898\u4e0a\u5408\u4f5c\uff0c\u5305\u62ec\u63a8\u8fdb\u8349\u6848\u6807\u51c6\u3002\u5f3a\u5927\u7684\u5f00\u53d1\u8005\u5e94\u8be5\u4f18\u5148\u8003\u8651\u91c7\u7528\u8fd9\u4e9b\u7279\u6027\uff0c\u6211\u4eec\u4e5f\u5728\u91cd\u70b9\u5e2e\u52a9\u7f51\u7ad9\u8fc7\u6e21\u4ee5\u96c6\u6210\u8fd9\u4e9b\u7279\u6027\u3002\u5bf9\u4e8eAJAX\u7279\u6027\u7684\u76f8\u5173\u793a\u4f8b\u4ee3\u7801\uff0c\u8bf7\u53c2\u8003Labs\u4e0a\u6211\u4eec\u7684IE8 AJAX Beta 2<a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=128984\" target=\"_blank\" title=\"\u624b\u518c\">\u624b\u518c<\/a>\u3002<\/p>\n<p>Sunava Dutta <br \/>Program Manager<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Updates for AJAX in IE8 Beta 2 IE 8 Beta 2\u4e2d\u7684AJAX\u65b0\u529f\u80fd \u539f\u6587\u5730\u5740\uff1ahttp:\/\/blogs.msdn.com\/ie\/archive\/2008\/10\/06\/updates-for-ajax-in-ie8-beta-2.aspx Sunava Dutta here, a program manager focused on improving AJAX in the browser! Now that Internet Explorer 8 Beta 2 is out, I want to write about some of the latest rounds of enhancements we\u2019ve made. As many of you may recall, back &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[120,134],"class_list":["post-593","post","type-post","status-publish","format-standard","hentry","category-coding","tag-AJAX","tag-IE"],"views":15997,"_links":{"self":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/comments?post=593"}],"version-history":[{"count":0,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/593\/revisions"}],"wp:attachment":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/media?parent=593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/categories?post=593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/tags?post=593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}