Determine if browser is drag-and-drop capable?

后端 未结 5 556
礼貌的吻别
礼貌的吻别 2021-01-03 00:43

I\'m implementing jQuery File Upload and trying to figure out the best way to detect whether the client can support drag & drop so I can render something like \'Drag &am

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-03 01:12

    I am in the same issue and tried with checking both window.FileReader && Modernizr.draganddrop as you said. This is my test output:

    IE window.FileReader==undefined && Modernizr.draganddrop==true
    OPERA window.FileReader==window.FileReader && Modernizr.draganddrop==false
    CHROME window.FileReader==window.FileReader && Modernizr.draganddrop==true
    FIREFOX window.FileReader==window.FileReader && Modernizr.draganddrop==true
    SAFARI window.FileReader==undefined && Modernizr.draganddrop==true
    

    So, your condition takes out the D&D non-supported browsers IE and OPERA. But it additionally drops SAFARI which supports drag and drop.

    In this case we can add jQuery.browser checking too to drop IE and OPERA.

提交回复
热议问题