jquery.support来检测JavaScript的File API? [英] jquery.support to detect JavaScript's File API?
问题描述
我找不到检测浏览器是否支持文件API 的方法jQuery中的 .support
方法。
I can't find the way to detect if the browser supports the File API through the .support
methon in jQuery.
任何人都知道吗?
(顺便提一下:一种在<$ c中检测文件大小的方法$ c>用IE输入[type = file] ?
(Incidentally: a way to detect the size of a file in input[type=file]
with IE?)
推荐答案
它似乎没有在jQuery中实现,但你可以自己检查一下: http://jsfiddle.net/pimvdb/RCz3s/。
It does not seem to be implementd in jQuery, but you could check yourself: http://jsfiddle.net/pimvdb/RCz3s/.
的
返回一个空的文件
属性< input type ='file'> ; FileList
如果它已实现,否则它没有定义(即它是 undefined
)。
The files
property of an <input type='file'>
returns an empty FileList
if it's implemented, and otherwise it is not defined (i.e. it is 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
})();
这篇关于jquery.support来检测JavaScript的File API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!