jquery.support来检测JavaScript的File API? [英] jquery.support to detect JavaScript's File API?

查看:98
本文介绍了jquery.support来检测JavaScript的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆