我有一个带有特定输入字段的 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-filesdocument 的 url.文档
.
The resource could be a local file, resulting in a url like file:///home/me/document
or file://c:windows-filesdocument.doc
.
该资源也可以是一个网络资源,产生一个像 http://host.nl/document.doc
甚至 ftp://host.nl/document 这样的 url.doc
,尽管此时我对 ftp 资源并不感兴趣.我假设来自网络浏览器的地址栏中的网页 url 的 dnd 操作,或者来自例如客户端计算机上的文件的 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.
与 Web 应用程序一样,我希望此功能可以在大多数平台上运行.(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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!