How to determine presence of HTML5 drag'n'drop file upload API (like the one from FF3.6)

前端 未结 8 704
一生所求
一生所求 2020-12-01 04:53

I am writing an application that\'s supposed to support HTML5 drag/drop API for file, much like the on described here. I would like to perform a programmatic check on whethe

8条回答
  •  遥遥无期
    2020-12-01 05:23

    If you don't want to deal with Modernizr at all, you can just replicate what it does for drag'n'drop detection:

    var supportsDragAndDrop = function() {
        var div = document.createElement('div');
        return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div);
    }
    

    Got it from Modernizr GitHub repository:

    https://github.com/Modernizr/Modernizr/blob/master/feature-detects/draganddrop.js

提交回复
热议问题