获取拖放资源的URL字段 [英] Get URL of resource that is drag-and-dropped on field
问题描述
我有一个带有某个输入字段的html页面,我想添加以下功能。
I have an html page with a certain input field and I want to add the following functionality.
用户应该可以将资源拖放到领域。该操作的结果应该是该资源的URL出现在该字段中。
The user should be able to drag and drop a resource onto the field. The result of this action should be that the url of the resource appears in the field.
资源可能是本地文件,导致像 file:/// home / me / document
或 file:// c:\windows-files\document.doc
。
The resource could be a local file, resulting in a url like file:///home/me/document
or file://c:\windows-files\document.doc
.
资源也可以是一个网页资源,导致像 http://host.nl/document.doc
甚至 ftp://host.nl/document.doc
,虽然在这一点上,我对ftp资源并不感兴趣。我假定网页浏览器的地址栏中的网页网址的动作,或客户端机器上的文件的dnd操作。桌面。
The resource could also be a web resource, resulting in a url like http://host.nl/document.doc
or even ftp://host.nl/document.doc
, although at this point I'm not really interested in ftp resources. I'm assuming a dnd-action of a web-page url from the address bar of a web browser, or a dnd-action of a file on the client machine from e.g. the desktop.
像往常一样的网络应用程序,我希望这个功能在大多数平台上运行。 (Linux / Win / MacOS,Firefox / Chrome / Safari / IE / Opera)
As usual for web apps, I want this functionality to work on most platforms. (Linux/Win/MacOS, Firefox/Chrome/Safari/IE/Opera)
范例是html和JavaScript。
The paradigm is html and JavaScript.
推荐答案
在Firefox中,您可以使用file.mozFullPath。
但是,此变量仅在Firefox中显示,并且不适用于Chrome或Safari。
In Firefox you can use file.mozFullPath. However, this variable presents only in Firefox and don't work in Chrome or Safari.
这篇关于获取拖放资源的URL字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!