HTML5 Drag and drop function

Source: Internet
Author: User

local file dragged to page instance: (ie supported)
<script> var dragfile = function (goalid) {var g = document.getElementById (Goalid);        Regdragfile (g, costfunc_file_ondrop);        };            var costfunc_file_ondrop = function (e, goalidobj) {var fileobj = e.datatransfer.files[0];            Create a stream to read the file var FileR = new FileReader (); Add a picture label to the Target field when the file is loaded filer.onload = function (e) {goalidobj.innerhtml = " 

  

  

page Element Drag instance: (ie not supported)
   /** * @author zzq */<script type= "Text/javascript" > var Act = {};         act.dragaction = undefined; (function () {var dragaction_goalarray = function (Goalidarray, SourceID) {Goalidarray = goal IDArray | |                [];                 var Exec = "";                for (var ele in Goalidarray) {Exec + = Dragaction (Goalidarray[ele], SourceID) + "";            } return new Function (Exec);             };                var dragaction = function (Goalid, SourceID) {var g = document.getElementById (Goalid);                 var s = document.getElementById (SourceID);            Regdragaction (g, S, Cust_ondrop, Cust_ondragstart);             }; var cust_ondrop = function (e, goalidobj) {var tmpobj = document.getElementById (E.datatransfer.getdata ("SI                D "));            Goalidobj.appendchild (Tmpobj);             }; var Cust_ondragstart = function (E,SourceID) {//essence is a data slot passed to the handle (so the first parameter can be customized) e.datatransfer.setdata ("SId", SourceID);             }; var regdragaction = function (Goalidobj, sourceidobj, Costfunc_ondrop, Costfunc_ondragstart) {Goalidobj.on                DragOver = function (e) {//block system default action (before and after operation) E.preventdefault ();                 };                     Goalidobj.ondrop = function (e) {//block system default action (before and after operation) E.preventdefault ();                User-defined function Costfunc_ondrop (e, this);                 }; Sourceidobj.ondragstart = function (e) {//user-defined function Costfunc_ondragstart (E, This.geta                Ttribute ("id"));            };             };         Act.dragaction = Dragaction_goalarray;          })();             onload = function () {var Ary = ["A2", "A3", "A4"];        Act.dragaction (Ary, "A1"); } </script>

  

HTML5 Drag and drop function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.