IE10 in Windows 8 Release Preview updates
the
responseXML from an XMLHttpRequest to return a nativeXML document by default. This change applies to IE10’s Standards and Quirks
document modes, making them interoperable with other modern browsers and consistent
with a “same markup” approach. Compatibility document modes 5, 7, 8, and 9 are unchanged.
This change may impact sites that were expecting
responseXML to containan MSXML document and depended on MSXML-specific functionality such as
selectNodes. In these cases, you may request that IE10 return an MSXML by settingthe
responseType member of your XMLHttpRequest object to 'msxml-document'. If your code does not depend on MSXML-specific functionality, IE10’s native XML document should work for you.Native XML support in IE9 brought DOM parity to XML and HTML and enabled XML fragments
to be inserted and rendered directly within a page (even in HTML). IE9 also simplified
converting between XML and DOM with the addition of
DOMParser and XMLSerializer. IE10 completes this transition by updating
responseXML to return a native XML document.Like IE9, IE10 previews before the Windows 8 Release
Preview returned an
MSXML document for
responseXML. As a result, retrievinga native document required the additional step of passing
responseTextto
DOMParser.var xhr = new
XMLHttpRequest();//...var parser = new
DOMParser();var doc = parser.parseFromString(xhr.responseText,
'text/xml');// 'doc' contains a native document
in both IE9 and IE10DOMParserstep by returning a native document directly via
responseXML. Existingcode using
DOMParser will continue to work in IE10.var xhr = new
XMLHttpRequest();//...var doc = xhr.responseXML;// 'doc' contains a native document
in IE10’s Standards and Quirks document modes// it contains an MSHTML document
in IE9 and in IE10’s compatibility document modesresponse property whenresponseType is set to 'document'.var xhr = new
XMLHttpRequest();xhr.open(method, url, true);xhr.responseType = 'document';//...var doc = xhr.response;// 'doc' contains a native document
in IE10’s Standards and Quirks document modesThis can be useful if you still need some MSXML-specific functionality (such as
selectNodes) or simply need some extra time to migrate. To do this, setthe
responseType of your XMLHttpRequest object to 'msxml-document'.var xhr = new
XMLHttpRequest();xhr.open(method, url, true);try { xhr.responseType =
'msxml-document'; } catch(e){}//...var doc = xhr.responseXML;// 'doc' now contains an MSXML document
in IE10’s Standards and Quirks document modesdo throw an exception. You can defend against this using a
try/catchstatement, as in the above example.
—Tony Ross, Program Manager, Internet Explorer
DIGITAL JUICE
No comments:
Post a Comment
Thank's!