Aro*_*ost 8 html javascript html5 w3c
我想知道浏览器是否支持XMLHttpRequest.responseType = "arraybuffer".问题是,我无法再次测试一些"通用"xhr2支持,因为iOS 4.2具有部分xhr2支持,包括(即)XMLHttpRequestUpload但不支持responseType = "arraybuffer".
bwi*_*els 10
我使用以下内容:
var supported = typeof new XMLHttpRequest().responseType === 'string';
Run Code Online (Sandbox Code Playgroud)
在我测试的所有支持它的浏览器中,responseType的默认值是一个空字符串(就像它在规范中所说:http://www.w3.org/TR/XMLHttpRequest/#the-responsetype-attribute),不支持responseType的浏览器未定义属性的值.
你尝试过这样的事情吗?
if(typeof(XMLHttpRequestUpload) == "undefined"){
//not supported
}
Run Code Online (Sandbox Code Playgroud)
编辑
我想你可能会被这样讨厌的事情困住
function IsArrayBufferSupported(){
var xhr = new XMLHttpRequest();
xhr.open('GET', '/', true);
try{
xhr.responseType = "arraybuffer";
return true;
}catch(e){return false;}
}
Run Code Online (Sandbox Code Playgroud)