最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to detect browser supports this HTML5 feature - Stack Overflow

programmeradmin0浏览0评论

I want to detect (using javascript/jQuery) whether the user's browser supports multiple attribute to input type='file' tag. A feature of HTML5 to add multiple images.

<input type=file  name="images" value=" " multiple=""/>

Please suggest me how can i do this.

I want to detect (using javascript/jQuery) whether the user's browser supports multiple attribute to input type='file' tag. A feature of HTML5 to add multiple images.

<input type=file  name="images" value=" " multiple=""/>

Please suggest me how can i do this.

Share Improve this question asked May 5, 2012 at 13:19 Rusi NovaRusi Nova 2,6656 gold badges35 silver badges48 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 6
var i = document.createElement("input");
if (typeof i.multiple !== 'undefined') {
    // supports multiple
}

you can use modernizr which is developed for this purpose.

http://modernizr./

you can detect support of a feature like placeholder in this way:

if (!Modernizr.input.placeholder) {

}

As taken & edited from the Modernizr source:

var inputElem = document.createElement('input');
var multipleSupport = !!(multiple in inputElem);

You don't need to include a plete library if this is the only thing you need.

I suggest you use Modernizr javascript library? This provides a way to check if browsers support various features.

You can use Modernizr, which does a huge number of these tests for you.

In this case, though, the test is really easy:

if (typeof document.createElement('input').multiple !== "undefined") {
    // ... yes, it has it
}

The same is true of all the other new properties on elements.

发布评论

评论列表(0)

  1. 暂无评论