@@ -78,18 +78,20 @@ <h1>Drag and drop</h1>
78
78
text-shadow : # 000 2px 2px 2px ;
79
79
}
80
80
</ style >
81
+ < div id ="log "> </ div >
81
82
< article >
82
83
< p > Drag the list items over the dustbin, and drop them to have the bin eat the item</ p >
83
84
< div id ="bin " class ="over "> </ div >
84
85
< ul >
85
- < li > < a id ="one " href ="http://html5demos.com/drag # " draggable ="true "> one</ a > </ li >
86
- < li > < a href ="http://html5demos.com/drag # " id ="two " draggable ="true "> two</ a > </ li >
87
- < li > < a href ="http://html5demos.com/drag # " id ="three " draggable ="true "> three</ a > </ li >
88
- < li > < a href ="http://html5demos.com/drag # " id ="four " draggable ="true "> four</ a > </ li >
89
- < li > < a href ="http://html5demos.com/drag # " id ="five " draggable ="true "> five</ a > </ li >
86
+ < li > < a id ="one " href ="# " draggable ="true "> one</ a > </ li >
87
+ < li > < a href ="# " id ="two " draggable ="true "> two</ a > </ li >
88
+ < li > < a href ="# " id ="three " draggable ="true "> three</ a > </ li >
89
+ < li > < a href ="# " id ="four " draggable ="true "> four</ a > </ li >
90
+ < li > < a href ="# " id ="five " draggable ="true "> five</ a > </ li >
90
91
</ ul >
91
92
</ article >
92
93
< script >
94
+ function logit ( msg ) { document . getElementById ( 'log' ) . innerHTML += msg + '<br/>' ; }
93
95
94
96
var eat = [ 'yum!' , 'gulp' , 'burp!' , 'nom' ] ;
95
97
var yum = document . createElement ( 'p' ) ;
@@ -104,7 +106,7 @@ <h1>Drag and drop</h1>
104
106
105
107
addEvent ( el , 'dragstart' , function ( e ) {
106
108
e . dataTransfer . effectAllowed = 'copy' ; // only dropEffect='copy' will be dropable
107
- alert ( this . id ) ;
109
+ logit ( "setting id: " + this . id ) ;
108
110
e . dataTransfer . setData ( 'Text' , this . id ) ; // required otherwise doesn't work
109
111
} ) ;
110
112
}
@@ -120,7 +122,6 @@ <h1>Drag and drop</h1>
120
122
121
123
// to get IE to work
122
124
addEvent ( bin , 'dragenter' , function ( e ) {
123
- alert ( e . dataTransfer . getData ( 'Text' ) ) ;
124
125
this . className = 'over' ;
125
126
return false ;
126
127
} ) ;
@@ -134,6 +135,7 @@ <h1>Drag and drop</h1>
134
135
if ( e . preventDefault ) e . preventDefault ( ) ;
135
136
136
137
// alert(e.dataTransfer.getData('Text'));
138
+ logit ( "getting id: " + e . dataTransfer . getData ( 'Text' ) ) ;
137
139
var el = document . getElementById ( e . dataTransfer . getData ( 'Text' ) ) ;
138
140
// alert(el);
139
141
0 commit comments