您的位置:首页 > 编程语言 > Go语言

模拟google首页动画图标的

2008-12-15 23:48 585 查看


<div id="testit" style="width:50px; height:32px; background-image:url(bg.png);background-repeat:no-repeat;background-position:0px 0px;" onmouseover="popup();" onmouseout="popdn();"></div>
<script language="javascript">
var te=0;
var te2=5;
var arrbg=new Array();
var doit
var doit1
arrbg[0]="0px 0px";
arrbg[1]="-51px 0px";
arrbg[2]="-103px 0px";
arrbg[3]="-155px 0px";
arrbg[4]="-207px 0px";
arrbg[5]="-207px 3px";

function popup(){
te=0;
doit=setInterval("pp()",50);//隔50毫秒运行pp()
}
function pp(){
if(te<=5){
document.getElementById("testit").style.backgroundPosition=arrbg[te];
te=te+1;
}
else{
clearInterval(doit);
}
}

function popdn(){
te2=5;
doit1=setInterval("pd()",50);
}
function pd(){
if(te2>=0){
document.getElementById("testit").style.backgroundPosition=arrbg[te2];
te2=te2-1;
}
else{
clearInterval(doit1);
}
}

</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: