南通网络公司:让层抖动的效果源码
当你进行QQ或者MSN聊天的时候,为了让别人注意一下,你肯定会使用它的抖动功能,这样的话,他的页面就会抖动!这边也介绍一下让层抖动的代码,大家可以不妨尝试一下哦!
<!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>
<meta http-equiv="Content-Language" content="zh-cn" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="robots" content="all" />
<meta name="author" content="在远方┊jscode.cn" />
<meta name="Copyright" content="copyright (c) 2008 www.jscode.cn" />
<title>让层抖动的效果,msn,qq窗体震动效果 - 网页特效观止-网页特效代码|www.JsCode.CN|</title>
<style type="text/css">
#body{text-align:center;}
#test{width:200px;position:absolute;margin:10px auto;height:100px;border:2px dotted red;text-align:center}
</style>
</head>
<body>
<div style="margin:10px 200px">
<div>
<input type="button" value="~~~让我抖抖吧~~" onclick="nn.start()" /></div>
<div>
<input type="button" value="别抖了眼睛晕的很" onclick="nn.stop()" /></div>
<div id="test">
<br>
<a href="http://www.jscode.cn">网页特效观止</a><br>
<img border="0" src="/administrator/htmledit/UploadFile/2010128134543262.gif"></div>
</div>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>更多网页特效代码尽在 <a href="http://www.jscode.cn/">网页特效观止</a></p>
</body>
</html>
<script type="text/javascript">
var m=document.getElementById("test");
function SKclass (obj,Rate,speed) {
var oL=obj.offsetLeft;
var oT=obj.offsetTop;
this.stop=null;
this.oTime=null;
var om=this;
this.start=function(){
if(parseInt(obj.style.left)==oL-2){
obj.style.top=oT+2+"px";
setTimeout(function(){obj.style.left=oL+2+"px"},Rate)
}
else{
obj.style.top=oT-2+"px";
setTimeout(function(){obj.style.left=oL-2+"px"},Rate)
}
this.oTime=setTimeout(function(){om.start()},speed);
}
this.stop=function(){
clearTimeout(this.oTime);
}
}
var nn=new SKclass(m,20,70);
</script>