我确信可以将文件拖到浏览器内的 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.
发布评论
评论(3)
我认为不可能将文件拖到页面中。
尽管某些浏览器可能允许您将文件拖到文件上传输入框中。 如果到此为止,也许您可以通过 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.
您可以使用 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/
展示如何使用小程序支持拖放的文章位于:
还有另一篇文章展示了如何仅使用 JavaScript 来执行此操作。 这需要 HTML5,但效果很好。
The article which shows how to support drag and drop with an applet is at:
There's another article which shows how to do this with just JavaScript. This requires HTML5, but it works well.