Get URL of resource that is drag-and-dropped on field(获取在字段上拖放的资源的 URL)
问题描述
我有一个带有特定输入字段的 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:获取在字段上拖放的资源的 URL


- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01