确定浏览器是否支持拖放功能? [英] Determine if browser is drag-and-drop capable?

查看:25
本文介绍了确定浏览器是否支持拖放功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实施 jQuery File Upload 并试图找出检测客户端是否可以的最佳方法支持拖拽放下,这样我就可以渲染像'Drag &仅当他们确实可以这样做时,才将文件放到此处上传.

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 & drop files here to upload' only if they can actually do that.

在插件代码中,我可以看到一个函数 isXHRUploadCapable 几乎似乎与拖动 &放弃支持,但我认为这比任何事情都更巧合.(它使用 iFrames 发布上传,而不是 IE 和 Opera 的 XMLHTTPRequest 上传).看不到任何可以让我知道是否支持拖放的信息,所以我怀疑这只是一个事件发生或没有发生.

In the plugin code I can see a function isXHRUploadCapable which almost seems to correlate with drag & drop support, but I think that's more coincidental than anything. (It uses iFrames to post the upload rather than XMLHTTPRequest uploads for IE and Opera). Couldn't see anything that will let me know if drag-drop is supported, so I suspect it's just either an event happens or doesn't.

文档说Windows 版本的 Safari 不支持拖放.MSIE 和 Opera 不支持拖放、多文件选择或上传进度指示."所以,也许只有 Windows 版本的 Safari 支持 XMLHTTPRequest 上传,但不支持拖拽 &掉落?

The docs say "Drag & Drop is not supported on the Windows version of Safari. MSIE and Opera have no support for Drag & Drop, multiple file selection or upload progress indication." So, perhaps, just the Windows version of Safari supports XMLHTTPRequest uploads, but not drag & drop?

无论如何 - 我正在尝试找出检测浏览器是否支持拖动 & 的最佳方法.使用这个插件删除上传,我不知道我会怎么做.拖放功能是我可以轻松测试的吗?我该怎么做?此功能是否将取决于浏览器,或者取决于 Jquery Upload 是否专门支持该浏览器?

Anyway - I am trying to figure out the best way to detect whether or not a browser will support drag & drop uploads using this plugin, and I'm not sure how I would do this. Is drag and drop functionality something I can easily test? How would I do that? Is this functionality something that's going to depend on a browser, or on whether Jquery Upload specifically supports it for that browser?

推荐答案

Modernizr 是事实上的浏览器支持检测插件,支持拖放检测.

Modernizr is the de-facto browser support detection plugin and supports drag-and-drop detection.

在 Modernizr 1.5 中,我们测试以下拖动事件:

In Modernizr 1.5, we test for the following drag events:

  • 拖动
  • 拖动开始
  • 德拉格特
  • 拖拽
  • 拖动离开
  • 拖累
  • 放下

来源

这篇关于确定浏览器是否支持拖放功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆