【荐】JS实现的图片弹性拖动特效代码

代码简介:

很有意思的一个JavaScript代码段,鼠标怎么也甩不掉图片,像弹簧一样越甩越远,但就是甩不掉,用好了这一技巧,你就能做出很多漂亮的效果来。

代码内容:

View Code
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<title>【荐】JS实现的图片弹性拖动特效代码 - www.webdm.cn</title>
<STYLE>v\:* {
BEHAVIOR
: url(#default#VML)
}
</STYLE>

<SCRIPT language=JavaScript1.2>
var stringcolor="white"
var ballsrc="http://www.webdm.cn/themes/pic/webdm_logo.gif"
if (document.all && window.print){
document.write(
'<IMG id=Om style="LEFT: -10px; POSITION: absolute" src="'+ballsrc+'">')
ddx
=0;ddy=0;PX=0;PY=0;xm=0;ym=0
OmW
=Om.width/2;OmH=Om.height/2
}
function Ouille(){
x
=Math.round(PX+=(ddx+=((xm-PX-ddx)*3)/100))
y=Math.round(PY+=(ddy+=((ym-PY-ddy)*3-300)/100))
Om.style.left=x-OmW
Om.style.top
=y-OmH
elastoc.to
=x+","+y
elastoc.strokecolor
=stringcolor
setTimeout(
"Ouille()",1)
}
function momouse(){
xm
=window.event.x+5
ym
=window.event.y+document.body.scrollTop+15
elastoc.from
=xm+","+ym
}
if(document.all && window.print){
code
="<v:line id=elastoc style='LEFT:0;POSITION:absolute;TOP:0' strokeweight='1.5pt'></v:line>"} else {
code
="<v:group style='LEFT:-10;WIDTH:100pt;POSITION:absolute;TOP:0;HEIGHT:100pt' coordsize='21600,21600'><v:line

id=elastoc style='LEFT:0;WIDTH:100pt;POSITION:absolute;TOP:0;HEIGHT:100pt'

strokeweight='1.5pt'></v:line></v:group>
"}
if(document.all && window.print){
document.body.insertAdjacentHTML(
"afterBegin",code)
document.onmousemove
=momouse
Ouille()
}
</SCRIPT>
</head>
<BODY bgcolor="#000000">
</BODY>
</HTML>
<br />
<p><a href="http://www.webdm.cn">网页代码站</a> - 最专业的网页代码下载网站 - 致力为中国站长提供有质量的网页代码!

</p>

 

代码来自:http://www.webdm.cn/webcode/859c52fe-4f3d-4249-a2bc-6c45ff4da796.html

posted @ 2011-12-30 13:14  网页代码站  阅读(235)  评论(0编辑  收藏  举报