dengminhui 发表于 2013-2-7 19:23:58

使用Javascript进行drag&drop操作

使用Javascript进行drag&drop操作,示例代码如下:
 
这是drag&drop图片的例子:
<html><head><title>System Drag And Drop Example</title><script >function handleDragDropEvent(oEvent){var oTextbox =document.getElementById("text1");oTextbox.value+=oEvent.type+"\n";}</script></head><body><form><p>Try dragging the image.</p><p><img src="c:/1.jpg"alt="" ondragstart="handleDragDropEvent(event)" ondrag="handleDragDropEvent(event)" ondragend="handleDragDropEvent(event)" /></p><p><textarea rows="10" cols="25" readonly="readonly" id="text1"></textarea></P></form></body></html> 
 
 这是drag&drop文本的例子:
<html><head><title>System Drag And Drop Example</title><script >function handleDragDropEvent(oEvent){var oTextbox =document.getElementById("text1");oTextbox.value+=oEvent.type+"\n";}</script></head><body><form><p>Try dragging the text from the left textbox to the right one.</p><p><input type="text"value="drag the text" /><inputtype="text" ondragenter="handleDragDropEvent(event)"ondragover="handleDragDropEvent(event)" ondragleave="handleDragDropEvent(event)" ondrop="handleDragDropEvent(event)" /></p><p><textarea rows="10" cols="25" readonly="readonly" id="text1"></textarea></P></form></body></html> 
 
 
 
页: [1]
查看完整版本: 使用Javascript进行drag&drop操作