`
天梯梦
  • 浏览: 13631848 次
  • 性别: Icon_minigender_2
  • 来自: 洛杉矶
社区版块
存档分类
最新评论
阅读更多
<!--图片地址,请您自己更改!-->
<img src="http://www.qqbye.com/wawa/UploadFiles_3996/200807/2008071904350239_S.jpg" style="position:relative;" onMouseOver="init(this);rattleimage()" onMouseOut="stoprattle(this)" />
<script language="JavaScript">
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>
 

图片和浏览器的抖动

 

<style>
	#qq{position:relative;}
</style>

<script>
	mfx = function(isWin){
		var t = 0,z = 3,del = function(){clearInterval(mfx.ID);return mfx};
		del().ID = setInterval(function(){
			var i = t/180*Math.PI,x = Math.sin(i)*z,y = Math.cos(i)*z,s = qq.style;
			isWin ? window.moveBy(x,y) : (s.top=x+'px',s.left=y+'px');
			if((t += 90) > 1080)del();
		},30);
	}
</script>

<button onclick="mfx()">QQ</button>
<button onclick="mfx(1)">browser</button>
<img id="qq" src="http://dl.iteye.com/upload/picture/pic/57029/fe8a74ac-add2-396d-a298-2954c162bfe7.gif"  />
 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics