您的位置:首页 > 其它

一个层拖拽及鼠标跟随效果

2009-07-01 15:15 183 查看
<!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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: