需要在html中拖放文件 [英] Need to drag and drop a file in html

查看:115
本文介绍了需要在html中拖放文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含div标签的html文件。在浏览器中查看此html时,我想从桌面拖动文件并将其放入此html文件中(在浏览器中)。然后拖动的文件(例如jpeg)路径应该显示在div部分。如何在javascript中执行此操作。

I am having a html file containing a div tag.While viewing this html in browser,I want to drag a file from my desktop and drop it in this html file(in browser). Then the dragged file(ex. jpeg) path should display in the div portion.How to do this in javascript.

推荐答案

在HTML 4.0环境中,您不会(AFAIK)能够使用纯JS。您需要Silverlight,Flash或(天堂禁止)ActiveX控制器。 HTML 5.0具有DnD功能(我相信),但并非所有浏览器都支持它。

You won't (AFAIK) be able to do that with pure JS in an HTML 4.0 environment. You'll either need Silverlight, Flash or (heaven forbid) an ActiveX controller. HTML 5.0 has DnD capabilities (I believe) but not all browsers suport it.

http://html5doctor.com/native-drag-and-drop/

应该给你一些想法关于它是如何工作的:)

that should give you some idea about how it works :)

这篇关于需要在html中拖放文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆