我找不到通过jQuery中的.support方法来检测浏览器是否支持File API的方法。
有人知道吗?
(顺便说一句:一种用IE检测input[type=file]中文件大小的方法?)
发布于 2011-09-09 19:47:44
它似乎没有在jQuery中实现,但您可以自己检查一下:http://jsfiddle.net/pimvdb/RCz3s/。
<input type='file'>的files属性如果已实现则返回空FileList,否则未定义(即为undefined)。
var support = (function(undefined) {
return $("<input type='file'>") // create test element
.get(0) // get native element
.files !== undefined; // check whether files property is not undefined
})();发布于 2013-03-30 05:39:11
另一种检查方法是检查是否存在File API类型:
var FileApiSupported = !!('File' in window &&
'FileReader' in window &&
'FileList' in window &&
'Blob' in window);https://stackoverflow.com/questions/7361072
复制相似问题