2006-11-15

Javascript 元素拖曳操作(兼容IE,Opera,Firefox)

来源: CSDN 作者:佚名 评论 0 条
 
  • if(limit){
  • var op=obj.parentNode;
  • var opX=parseInt(op.style.left);
  • var opY=parseInt(op.style.top);
  • if((e.clientX-x_)<0) return false;
  • else if((e.clientX-x_ obj.offsetWidth opX)>(opX op.offsetWidth)) return false;
  • if(e.clientY-y_<0) return false;
  • else if((e.clientY-y_ obj.offsetHeight opY)>(opY op.offsetHeight)) return false;
  • //status=e.clientY-y_;
  • }
  • obj.style.left=e.clientX-x_ 'px';
  • obj.style.top=e.clientY-y_ 'px';
  • inFstop(e);
  • } // shawl.qiu script
  • function inFup(e){
  • var evt;
  • if(!e)e=window.event;
  • if(document.removeEventListener){
  • document.removeEventListener('mousemove', inFmove, true);
  • document.removeEventListener('mouseup', inFup, true);
  • } else if(document.detachEvent){
  • document.detachEvent('onmousemove', inFmove);
  • document.detachEvent('onmouseup', inFup);
  • }
  • inFstop(e);
  • } // shawl.qiu script
  • function inFstop(e){
  • if(e.stopPropagation) return e.stopPropagation();
  • else return e.cancelBubble=true;
  • } // shawl.qiu script
  • function inFabort(e){
  • if(e.preventDefault) return e.preventDefault();
  • else return e.returnValue=false;
  • } // shawl.qiu script
  • }
  • //]]>
  • </script>
  • </head>
  • <body>
  • <div style=" border:1px dashed blue; width: 760px; height:600px; text-align:center; position:absolute; left:100px; top: 10px;"> this parent
  • <div style=" border:1px dashed blue; width: 180px; text-align:center; position:absolute; left:50px; top: 50px;" onmousedown="fDragging(this, event, true);">
  • element <br/>
  • dragging compatibility for IE, Opera, Firefox.
  • </div>
  • <div style=" border:1px dashed blue; width: 180px; text-align:center; position:absolute; left:100px; top: 150px;" onmousedown="fDragging(this, event, true);">
  • element 1<br/>
  • dragging compatibility for IE, Opera, Firefox.
  • </div>
  • <div style=" border:1px dashed blue; width: 180px; text-align:center; position:absolute; left:200px; top: 250px;" onmousedown="fDragging(this, event, false);">
    共3页: 上一页 [1] 2 [3] 下一页
  • (本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
    上一篇:DHTML实现可控制的页面内滚动区域  
    下一篇:有关HTML代码的另类应用技巧
      评论加载中…

    网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
    Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号