发信人: marsz()
整理人: microant(1999-08-02 12:13:18), 站内信件
|
实例:可拖动的元素
适用浏览器:IE4+
说明:在图片或文字上点鼠标左键,按住,并拖动,可把选定元素拖动到任意位 置。
第一步:将下列代码复制到网页的Head和Body标记中间。
<style>
<!--.drag{position:relative;cursor:hand}-->
</style>
<script language="JavaScript1.2">
<!--
/*modified by mars ,www.joysoft.net*/
var dragapproved=falsevar z,x,yfunction move(){if (event.button==1&&dr agapproved){z.style.pixelLeft=temp1+event.clientX-xz.style.pixelTop=te mp2+event.clientY-yreturn false}}function drags(){if (!document.all)re turnif (event.srcElement.className=="drag"){dragapproved=truez=event.s rcElementtemp1=z.style.pixelLefttemp2=z.style.pixelTopx=event.clientXy =event.clientYdocument.onmousemove=move}}document.onmousedown=dragsdoc ument.onmouseup=new Function("dragapproved=false")//-->
</script>
第二步:建立如下页面:
<html>
<head>
<!--将第一步的代码复制到这里-->
</head>
<body>
<img src="test.gif" class="drag"><br>
<img src="test2.gif" class="drag"><br>
<h1 class="drag">"Hi there</h1>
</body>
</html>
-- ________________________________________________
欢迎访问飞翔鸟软体驿站: HTTP://JOYSOFT.SOIM.NET
BEST REGUARDS, MARS MAILTO:[email protected]
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.99.13.143]
|
|