资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
兼容IE FF Opera的javascript最短的拖动代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20language%3D%22JavaScript%22%20type%3D%22text%2Fjavascript%22%3E%20%0D%0Avar%20x%2Cy%20%0D%0Avar%20drag_%3Dfalse%20%0D%0Avar%20D%3Dnew%20Function('obj'%2C'return%20document.getElementById(obj)%3B')%20%0D%0Avar%20IE%3Dnew%20Function(''%2C'if(navigator.appName.indexOf(%22Explorer%22)%3E%3D0)return%201%3Bif(navigator.appName.indexOf(%22Netscape%22)%3E%3D0)return%202')%20%0D%0Afunction%20Move_obj(obj)%7B%2F%2F1%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20D(obj).onmousedown%3Dfunction(e)%7Bdrag_%3Dtrue%2F%2F4%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20with(this)%7Bstyle.position%3D%22absolute%22%3Btemp1%3DoffsetLeft%3Btemp2%3DoffsetTop%3B%2F%2F5%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(IE()%3D%3D1)%7Bx%3Devent.clientX%3By%3Devent.clientY%2F%2F6%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20document.onmousemove%3Dfunction(e)%7B%2F%2F7%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(drag_%3D%3Dfalse)return%20false%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20with(this)%7Bstyle.left%3Dtemp1%2Bevent.clientX-x%2B%22px%22%3Bstyle.top%3Dtemp2%2Bevent.clientY-y%2B%22px%22%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2F%2F7%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2F%2F6%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(IE()%3D%3D2)%7Bx%3De.pageX%3By%3De.pageY%3B%2F%2F8%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20document.onmousemove%3Dfunction(e)%7B%2F%2F9%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(drag_%3D%3Dfalse)return%20false%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20with(this)%7Bstyle.left%3Dtemp1%2Be.pageX-x%2B%22px%22%3Bstyle.top%3Dtemp2%2Be.pageY-y%2B%22px%22%7D%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2F%2F9%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2F%2F8%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2F%2F5%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20document.onmouseup%3Dnew%20Function(%22drag_%3Dfalse%22)%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%2F%2F4%20%0D%0A%7D%2F%2F1%20%0D%0A%3C%2Fscript%3E"> <body> <div id="test" style="background-color:#0099CC;width:200px"onmouseover='Move_obj("test")'>这个是可以拖动的层</div>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程