Code:
<!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" xml:lang="en" lang="en">
<head>
<title></title>
<style>
.shakeimage{
position:relative
}
</style>
<script language="JavaScript1.2">
/*
Shake image script (onMouseover)-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
function shake(which,by,ms){
shake.obj?shake.obj.style.top=shake.obj.style.left='0px':null;
which=typeof(which)=='object'?which:document.getElementById(which);
clearTimeout(shake.to);
if (which){
shake.obj=which;
rattleimage(which,typeof(by)=='number'?by:3,0,typeof(ms)=='number'&&ms>50?ms:50);
}
}
function rattleimage(obj,by,nu,ms){
obj.style[nu%2==0?'left':'top']=by*(nu/2>=1?-1:1)+'px';
nu=++nu%4;
shake.to=setTimeout(function(){ rattleimage(obj,by,nu,ms); },ms);
}
</script></head>
<body>
<img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img" class="shakeimage" onmouseover="shake(this);" onmouseout="shake();"/></body>
<br />
<br />
<a onmouseover="shake('tst',10,200);" onmouseout="shake();">LINK</a>
<br />
<img id="tst" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img" class="shakeimage" /></body>
<br />
<br />
<img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img" class="shakeimage" onmouseover="shake('tst',5,50);" onmouseout="shake();"/></body>
</html>
Bookmarks