资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
代码短小的js div层拖动实现代码[兼容IE与Firefox]
<img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%20%0D%0Avar%20ie%3Ddocument.all%3B%20%0D%0Avar%20nn6%3Ddocument.getElementById%26%26!document.all%3B%20%0D%0Avar%20isdrag%3Dfalse%3B%20%0D%0Avar%20x%2Cy%3B%20%0D%0Avar%20dobj%3B%20%0D%0Afunction%20movemouse(e)%20%0D%0A%7B%20%0D%0Aif%20(isdrag)%20%0D%0A%7B%20%0D%0Adobj.style.left%20%3D%20nn6%20%3F%20tx%20%2B%20e.clientX%20-%20x%20%3A%20tx%20%2B%20event.clientX%20-%20x%3B%20%0D%0Adobj.style.top%20%3D%20nn6%20%3F%20ty%20%2B%20e.clientY%20-%20y%20%3A%20ty%20%2B%20event.clientY%20-%20y%3B%20%0D%0Areturn%20false%3B%20%0D%0A%7D%20%0D%0A%7D%20%0D%0Afunction%20selectmouse(e)%20%0D%0A%7B%20%0D%0Avar%20fobj%20%3D%20nn6%20%3F%20e.target%20%3A%20event.srcElement%3B%20%0D%0Avar%20topelement%20%3D%20nn6%20%3F%20%22HTML%22%20%3A%20%22BODY%22%3B%20%0D%0Awhile%20(fobj.tagName%20!%3D%20topelement%20%26%26%20fobj.className%20!%3D%20%22dragme%22)%20%0D%0A%7B%20%0D%0Afobj%20%3D%20nn6%20%3F%20fobj.parentNode%20%3A%20fobj.parentElement%3B%20%0D%0A%7D%20%0D%0Aif%20(fobj.className%3D%3D%22dragme%22)%20%0D%0A%7B%20%0D%0Aisdrag%20%3D%20true%3B%20%0D%0Adobj%20%3D%20fobj%3B%20%0D%0Atx%20%3D%20parseInt(dobj.style.left%2B0)%3B%20%0D%0Aty%20%3D%20parseInt(dobj.style.top%2B0)%3B%20%0D%0Ax%20%3D%20nn6%20%3F%20e.clientX%20%3A%20event.clientX%3B%20%0D%0Ay%20%3D%20nn6%20%3F%20e.clientY%20%3A%20event.clientY%3B%20%0D%0Adocument.onmousemove%3Dmovemouse%3B%20%0D%0Areturn%20false%3B%20%0D%0A%7D%20%0D%0A%7D%20%0D%0Adocument.onmousedown%3Dselectmouse%3B%20%0D%0Adocument.onmouseup%3Dnew%20Function(%22isdrag%3Dfalse%22)%3B%20%0D%0A%3C%2Fscript%3E"> <div align="center"> <img src="http://www.glzy8.com/images/logo.gif" _ewebeditor_ta_src="http%3A%2F%2Fwww.glzy8.com%2Fimages%2Flogo.gif" style="position:relative;" width="210" height="96" class="dragme"> </div>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程