将文件从窗口拖放到 Javascript

发布于 2024-07-16 03:25:49 字数 238 浏览 6 评论 0 原文

我确信可以将文件拖到浏览器内的 Flash 影片上,但是是否可以使用 Javascript 实现相同的功能?

我见过一个网站(不记得了)这样做了,但我从未检查过与 Flash 解决方案相比它是否是纯 Javascript 解决方案。

我倾向于方面,我相信这打破了Javascript的限制,尽管如果有任何解决方案我很乐意听到。 我唯一担心的是它不会在不同的浏览器之间得到很好的支持。

I am sure it's possible to be able to drag files onto a Flash movie inside a browser, but is it possible to achieve the same functionality with Javascript?

I have seen a site (can't remember) that did this, but I never checked if it was a pure Javascript solution compared to a Flash solution.

I am leaning towards the not side, I believe that breaks the limitations of Javascript, although if there is any solution I would love to hear it. My only worry is it won't be supported that well across different browsers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

熟人话多 2024-07-23 03:25:49

我认为不可能将文件拖到页面中。

尽管某些浏览器可能允许您将文件拖到文件上传输入框中。 如果到此为止,也许您可​​以通过 CSS 拉伸这样的输入,并使其透明/覆盖在背景上,以提供“漂亮”的放置目标。

I don't think it's possible to drag a file into a page as such.

Though some browsers may allow you to drag a file into a file upload input box. If this is the cease, perhaps you could stretch such an input via CSS and make it transparent/overlay on background to provide a "pretty" drop target.

抽个烟儿 2024-07-23 03:25:49

您可以使用 ActiveX 来完成此操作,尽管它只能在 IE 中工作..这里有一篇文章描述了如何在 Firefox 中进行拖放上传 http://straxus.javadevelopersjournal.com/creating_a_mozillafirefox_drag_and_drop_file_upload_script_p.htm

没有一种适用于所有使用 javascript 的浏览器的通用方法 - 但您可以使用 java像这样的小程序: http ://www.zackgrossbart.com/hackito/2007/11/28/drag-and-drop-file-uploading-made-easy/

You can do this with ActiveX, though it would only work in IE.. and here is an article describing how to do a drag/drop upload in Firefox http://straxus.javadevelopersjournal.com/creating_a_mozillafirefox_drag_and_drop_file_upload_script_p.htm

There isn't a generic way of doing this that will work for all browsers with javascript - but you could use a java applet like this: http://www.zackgrossbart.com/hackito/2007/11/28/drag-and-drop-file-uploading-made-easy/

暖风昔人 2024-07-23 03:25:49

展示如何使用小程序支持拖放的文章位于:

http://www.zackgrossbart.com/hackito/dnd-file-uploading

还有另一篇文章展示了如何仅使用 JavaScript 来执行此操作。 这需要 HTML5,但效果很好。

http://www.thecssnin]ja.com/javascript/drag-and-drop-upload

The article which shows how to support drag and drop with an applet is at:

http://www.zackgrossbart.com/hackito/dnd-file-uploading

There's another article which shows how to do this with just JavaScript. This requires HTML5, but it works well.

http://www.thecssnin]ja.com/javascript/drag-and-drop-upload
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文