JS layer jitter effect, similar to QQ chat window jitter, js window

Source: Internet
Author: User

JS layer jitter effect, similar to QQ chat window jitter, js window
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> JavaScript layer jitter </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 = "~ Click here to shake me up ~ "Onclick =" nn. start () "/> </div>
<Div>
<Input type = "button" value = "shake off. I'm not shaking! "Onclick =" nn. stop () "/> </div>
<Div id = "test">
<Br>
</div>
</Div>
<P> </p>
<P> </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>
<Div> <A href = "http://www.999jiujiu.com/"> http://www.999jiujiu.com/</A> </div>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.