SetCapture的使用问题,为什么不执行onmouseover事件?

xiezechang 2010-02-08 11:45:49

<html>
<head>
<title> Drag Demo 1 </title>
<style type="text/css">
<!--
#drag{
width:100px;
height:20px;
background-color:#eee;
border:1px solid #333;
position:absolute;
top:30px;
left:200px;
text-align:center;
cursor:default;
}
//-->
</style>
<script type="text/javascript">
<!--
window.onload=function(){
drag(document.getElementById('drag'));
};

function drag(o){
o.onmousedown=function(a){
var d=document;if(!a)a=window.event;
var x=a.layerX?a.layerX:a.offsetX,y=a.layerY?a.layerY:a.offsetY;
if(o.setCapture)
o.setCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);

d.onmousemove=function(a){
if(!a)a=window.event;
if(!a.pageX)a.pageX=a.clientX;
if(!a.pageY)a.pageY=a.clientY;
var tx=a.pageX-x,ty=a.pageY-y;
o.style.zIndex="-1";
o.style.left=tx;
o.style.top=ty;
};

d.onmouseup=function(){
if(o.releaseCapture)
o.releaseCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
d.onmousemove=null;
d.onmouseup=null;

};
};
}
//-->
</script>
</head>

<body>
<div id="drag">drag me</div>

<div style="left:200;top:200;width:100;height:100;background:#ccc;" onmouseover="alert('on');" onmouseout="alert('out')"></div>
</body>
</html>

...全文
128 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
shan1119 2010-02-08
  • 打赏
  • 举报
回复
your code is right.no problem
xiezechang 2010-02-08
  • 打赏
  • 举报
回复
引用 1 楼 shan1119 的回复:
your code is right.no problem

不对啊 拖拽时 他不执行onmouseover方法.......

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧