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

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

问题描述

我正在实施 jQuery文件上传,并尝试找出最好的方法来检测客户端是否可以支持拖&下拉,所以我可以渲染像'拖&下载文件在这里上传,只有当他们可以这样做。

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.

文档说 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?

推荐答案

<一个href =http://www.modernizr.com/ =noreferrer> 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:


  • 拖动

  • dragstart

  • dragenter

  • dragover

  • dragleave

  • dragend

  • drop

  • drag
  • dragstart
  • dragenter
  • dragover
  • dragleave
  • dragend
  • drop

来源

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

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