<html>
<head>
<title>窗口抖动效果</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
#qq {position: relative;}
</style>
</head>
<body>
<p>
<button οnclick="mfx('qq')">
图片抖动
</button>
<button οnclick="mfx('qq',1)">
IE下浏览器抖动
</button>
</p>
<img id="qq" src="http://www.baidu.com/img/baidu_sylogo1.gif" />
<script>
function mfx(objId,isWin){
var p_obj = document.getElementById(objId);
if(null == p_obj){
return;
}
/* 注销不停调用函数 */
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 = p_obj.style;
isWin?window.moveBy(x,y):(s.top = x+'px', s.left = y+'px');
if((t += 90) >= 1080){
del();
}
},30);
}
</script>
</body>
</html>
JavaScript-仿QQ窗口抖动
最新推荐文章于 2021-04-06 02:48:13 发布