AD
AD

css和javascript实现拖动效果

时间:2007-12-29 09:42:47  来源:  作者:
AD

       不知道大家进163的邮件有没有发现上面的邮件是可以拖动的,本想看看它的原码是如果实现,但由于本人水平太次,不能找到其中的原码,后面通过网上找到一些代码,修改了些基本上能实现此种效果,html代码如下:
<style>
<!--
.drag{position:relative;cursor:hand}
-->
</style>
<script >
<!--
var dragapproved=false
var z,x,y
var xx,yy 字串1

function move(){
if ( z==null){ ; return}
if (event.button==1&&dragapproved){
z.style.pixelLeft=temp1+event.clientX-x
z.style.pixelTop=temp2+event.clientY-y
return false
}
}
function moveto(){
z.style.pixelLeft= xx
z.style.pixelTop= yy
z=null
}
 
function drags(){
 
if (!document.all)return
if (event.srcElement.className=="drag"){
 
dragapproved=true
z=event.srcElement
if ( z==null){  return}
temp1=z.style.pixelLeft
temp2=z.style.pixelTop
xx=z.style.pixelLeft
yy=z.style.pixelTop
x=event.clientX
y=event.clientY
document.onmousemove=move

字串9

}
 
} 字串7

function drags1(){
if ( z==null){ ; return}
if (z.className=="drag"){
//z=event.srcElement
//alert(z.type);
temp1=z.style.pixelLeft
temp2=z.style.pixelTop
x=event.clientX
y=event.clientY
moveto()
} 字串1

}
document.onmousedown=drags
document.onmouseup=drags1

字串3

Function("dragapproved=false")
//-->
</script>
<html>
<body>
 <table CELLPADDING=0 CELLSPACING=0 width="630" align="center">
  <tr>
     <td align="center" colspan="9" height="60">
 <table bgcolor="blue" CELLPADDING=1 CELLSPACING=1 width="200" height="23" align="center" border=1>
  <tr>
     <td align="center" colspan="9" height="60">
       <font class="title1">自 荐 信</font>
     </td>
  </tr>
     <tr>
     <td colspan="9"  class="drag" height="27">尊敬的领导:<br>
&nbsp;&nbsp;&nbsp;&nbsp;您好!<br>
 <br>
&nbsp;&nbsp;此致<br>
敬礼 ! <br>
&nbsp;&nbsp;&nbsp;&nbsp; 自荐人:piliskys <br>
      字串9
     </td>
  </tr>
  <tr><td align="center">
  <input type=button  class="drag"   value=写邮件 style=width:78 />
  </td></tr>
  <tr  >
                  <td  class="drag">
                    姓
                    名:
                  </td>
                 
                </tr>
  </table>
  </td>
  </tr> 字串2
  </table>
</body>
</html>

字串7


文章评论

共有 0位编程爱好者发表了评论 查看完整内容

    评论加载中…
忒好程序员:www.teihao.com

推荐信息

     
忒好程序员
AD