HTML5的拖拽时间 ondragstart

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>dragable</title>
</head>
<body>
<h1 draggable="true">time</h1>
<span id="clock" draggable="true">time_span</span>
<img src="12.png" />
<textarea cols="60" rows="20"></textarea>
<script>
(function(){
var clock = document.getElementById('clock');
var icon = new Image();
icon.src = "12.png"; function displayTime(){
var now = new Date();
clock.innerHTML = now.getMinutes();
setTimeout(arguments.callee,6000);
};
displayTime(); clock.ondragstart = function(ev){
var dt = ev.dataTransfer; //event里面有一个dataTransfer,这栋西很重要,setData,就是将数据保存到一个缓冲中,然后,就可以放到textarea看到数据了
dt.setData("Text",Date(),"\n");
if(dt.setDargImage)dt.setDragImage(icon,0,0)
}
})()
</script>
</body>
</html>

//来自于西牛叔 p472页

上一篇:Spring拦截器中通过request获取到该请求对应Controller中的method对象


下一篇:windows下python3.4安装lxml提示"Unable to find vcvarsall.bat"