一个层拖拽及鼠标跟随效果
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<div id="dragDiv" style="z-index:9999;position: absolute; left:0; top:0;overflow:hidden;width:160;height:100%" onMouseDown="Start()" onMouseUp="End()">
hello world!
</div>
<script language="javascript" type="text/javascript">
var dv = document.getElementById("dragDiv").style;
var bDrag;
function document.onmousemove(){
if(bDrag && window.event.button==1){
dv.posLeft = window.event.clientX;
dv.posTop = window.event.clientY;
}
}
function Start(){
bDrag=true;
dv.cursor = "move";
}
function End(){
bDrag = false;
dv.cursor = "default";
}
</script>
</body>
</html>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<div id="dragDiv" style="z-index:9999;position: absolute; left:0; top:0;overflow:hidden;width:160;height:100%" onMouseDown="Start()" onMouseUp="End()">
hello world!
</div>
<script language="javascript" type="text/javascript">
var dv = document.getElementById("dragDiv").style;
var bDrag;
function document.onmousemove(){
if(bDrag && window.event.button==1){
dv.posLeft = window.event.clientX;
dv.posTop = window.event.clientY;
}
}
function Start(){
bDrag=true;
dv.cursor = "move";
}
function End(){
bDrag = false;
dv.cursor = "default";
}
</script>
</body>
</html>