很好玩的js -- 可以拖动
来源:互联网 发布:windows 性能指数 编辑:程序博客网 时间:2024/04/29 06:22
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="description"
content="Click here for a script that helps enable drag and drop on any image in the page!" />
<meta name="keywords" content="DHTML, drag and drop script, JavaScript, free" />
<title>Dynamic Drive DHTML Script- Dragable elements Script</title>
<style type="text/css">
.drag{
position:relative;
cursor:pointer;
z-index: 100;
}
</style>
<script type="text/javascript">
var dragobject={
z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
initialize:function(){
document.onmousedown=this.drag
document.onmouseup=function(){this.dragapproved=0}
},
drag:function(e){
var evtobj=window.event? window.event : e
this.targetobj=window.event? event.srcElement : e.target
if (this.targetobj.className=="drag"){
this.dragapproved=1
if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0}
if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0}
this.offsetx=parseInt(this.targetobj.style.left)
this.offsety=parseInt(this.targetobj.style.top)
this.x=evtobj.clientX
this.y=evtobj.clientY
if (evtobj.preventDefault)
evtobj.preventDefault()
document.onmousemove=dragobject.moveit
}
},
moveit:function(e){
var evtobj=window.event? window.event : e
if (this.dragapproved==1){
this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px"
this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px"
return false
}
}
}
dragobject.initialize()
</script>
</head>
<body>
<h1><b class="drag">用鼠标拖动DIV或图象(image)的JS源码</b></h1>
</body>
</html>
- 很好玩的js -- 可以拖动
- 很好玩的JS
- 学习css3过渡效果,可以实现很好玩的东西,无需js
- 一个很好玩的效果,可以作为很多特效使用
- 收集的很好玩的js前端漂浮鼠标跟随
- 怎样才能很好的玩转 ArcGIS API for JS?
- 一个很好玩的表
- 很好玩的聊天机器人
- 很好玩的滚动效果
- 很好玩的读心术~
- 很好玩的滚动效果
- 很好玩的滚动效果
- 两个很好玩的网站
- 很好玩的网站导航
- 很好玩的一个网站
- 看起来很好玩的样子.
- 第三十一天 用js写一个可以拖动的div
- 可以拖动的GridView
- Linux之C语言中如何抛出异常或将异常写入日志文件中
- C++使用Json作为数据包装格式的通信
- ExecutorService
- Java序列化基础事项回顾
- android popupwindow 对话框 添加外框 并修改
- 很好玩的js -- 可以拖动
- No tag "form" defined in tag library imported with prefix "s"
- 读 PetShop代码(Profile篇)
- Twitter Storm如何保证消息不丢失
- css技巧之a包住img
- dlut1013
- CSS+DIV做的可拖动带遮罩层的DIV,圆角也是用CSS实现
- jQuery中常用的函数方法总结
- SE16N And &SAP_EDIT