百度空间 | 百度首页 
               
 
查看文章
 
js实现窗口的拖动
2007-06-05 17:25

<html>
<head>
<script type="text/JavaScript"><!--
//注意,这里没有使用通用的捕获鼠标的模式,只是获取就算。
var d=0;
function move(f){
if(f==1){
   d=1;
}else if(f==2){
   d=0;
}else if(f==0&&d==1){
   me.style.posLeft=document.body.scrollLeft+event.clientX;
   me.style.posTop=document.body.scrollTop+event.clientY;
}
}
//--></script>

</head>
<body onmousemove="move(0)" onmousedown="move(1)" onmouseup="move(2)">
<div ID="me" style="position: absolute; left: 200px; top: 120px; width:300px; height:200px; visiblity: visible;">
<table border="1" width="100%" height="100%">
   <tr><td>请你进行拖拽</td></tr>
   <tr height="100%"><td>这可是一个会动的窗体啊</td></tr>
   <tr><td></td></tr>
</table>
</div>
</body>
</html>


类别:Ajax | 添加到搜藏 | 浏览() | 评论 (1)
 
最近读者:
 
网友评论:
1
2007-06-08 13:00 | 回复
楼主不知道测试过没有,我怎么在IE下可以拖动运行,在firefox下就不能呢?
 
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu