鼠标移至图片后抖动的JS代码

代码简介:

仿QQ的窗口抖动特效,鼠标移到到图片上面,图片就开始疯狂的抖动,好像对你的鼠标过敏一样,比较有意思,有会你的网页增加了修改功能。

代码内容:

View Code
<html>
<head>
<title>鼠标移至图片后抖动的JS代码 - www.webdm.cn</title>
</head>
<BODY>
<style>
.shakeimage
{
position
:relative
}
</style>
<img src=http://www.webdm.cn/images/wall1_s.jpg class="shakeimage" onMouseover="init(this);rattleimage()"

onMouseout
="stoprattle(this)">
<script language="JavaScript1.2">
var rector=3
var stopit=0
var a=1

function init(which){
stopit
=0
shake
=which
shake.style.left
=0
shake.style.top
=0
}

function rattleimage(){
if ((!document.all && !document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top
=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left
=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top
=parseInt(shake.style.top)-rector
}
else{
shake.style.left
=parseInt(shake.style.left)-rector
}
if (a<4)
a
++
else
a
=1
setTimeout(
"rattleimage()",50)
}

function stoprattle(which){
stopit
=1
which.style.left
=0
which.style.top
=0
}
</script>
</body>
</html>
<br />
<p><a href="http://www.webdm.cn">网页代码站</a> - 最专业的网页代码下载网站 - 致力为中国站长提供有质量的网页代码!

</p>

 

代码来自http://www.webdm.cn/webcode/1c36fac4-9137-4d1e-ad8e-028e3fa8effb.html

posted @ 2012-01-09 11:16  网页代码站  阅读(471)  评论(0编辑  收藏  举报