How to detect browser supports this HTML5 feature

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

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

Please suggest me how I can do this.

+4
source share
5 answers
 var i = document.createElement("input"); if (typeof i.multiple !== 'undefined') { // supports multiple } 
+6
source

You can use modernizr , which is designed for this purpose.

http://modernizr.com/

you may find support for a function like placeholder as follows:

 if (!Modernizr.input.placeholder) { } 
+2
source

As taken and edited from Modernizr source:

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

You do not need to include a complete library if this is the only thing you need.

+1
source

I suggest you use the JavaScript library for Modernizr? This makes it possible to check whether the browser supports various functions.

0
source

You can use Modernizr , which makes a huge amount of these tests for you.

In this case, the test is very simple:

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

The same applies to all other new element properties.

0
source

Source: https://habr.com/ru/post/1410853/


All Articles