让层抖动的效果,msn,qq窗体震动效果

2010-10-11 杜世伟 JavaScript

<!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="http://www.jscode.cn/images/logo.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>
 

Powered by emlog 沪ICP备2023034538号-1