[英]Detecting drag and drop with Modernizr (not file drag and drop)
I've spent a fair while looking for the answer to this question and either found answers that are out of date or answers that relate to file drag and drop. 我花了很长时间寻找这个问题的答案,并找到了过时的答案或与文件拖放有关的答案。
I just want to check if a user's browser supports HTML5 drag and drop. 我只想检查用户的浏览器是否支持HTML5拖放。 At the moment the line... 此刻线......
if (!Modernizr.draganddrop) {
// non-HTML5 alternative drag and drop code here
}
...returns true for any IE version I emulate. ...对于我模拟的任何IE版本,返回true。 Why does Modernizr think that IE doesn't support drag and drop at all? 为什么Modernizr认为IE根本不支持拖放? I read that IE9 onward does... 我读到IE9以后会...
Should I be checking the browser version instead? 我应该检查浏览器版本吗?
Any help, much appreciated. 任何帮助,非常感谢。
Just use javascript rather than Modernizr: 只需使用javascript而不是Modernizr:
function dragAndDropSupported () {
return 'draggable' in document.createElement('span');
}
Check to see if dragAndDropSupported() === true 检查dragAndDropSupported()===是否为true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.