JS实现鼠标指向图片抖动代码
代码简介:
一款比较平滑的图片抖动特效,鼠标放到图片上触发JS函数,记得QQ聊天有一个窗口抖动效果,和这个类似,很可爱。
代码内容:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JS实现鼠标指向图片抖动代码 - www.webdm.cn</title>
<style>
.shakeimage{
position:relative
}
</style>
<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>
</head>
<body>
<img src=http://www.webdm.cn/themes/pic/webdm_logo.gif class="shakeimage" onMouseover="init(this);rattleimage()"
onMouseout="stoprattle(this)">
<br>
鼠标放图片上看一下??让我抖抖~
</body>
</html>
<br />
<p><a href="http://www.webdm.cn">网页代码站</a> - 最专业的网页代码下载网站 - 致力为中国站长提供有质量的网页代码!
</p>
代码来自:http://www.webdm.cn/webcode/1b240bf4-fd97-4143-8b95-7853aa255390.html