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