JavaScript实现文字 上下跳动,或上下移动,比较普通的效果,类似QQ聊天窗口抖动一样的效果,只不过这里是图片而已。
<!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-Type" content="text/html; charset=gb2312" />
<title>草坪销售</title>
</head>
<body>
<script language="JavaScript">
<!--
done = 0;
step = 4
function anim(yp,yk)
{
if(document.layers) document.layers["napis"].top=yp;
else document.all["napis"].style.top=yp;
if(yp>yk) step = -4
if(yp<60) step = 4
setTimeout('anim('+(yp+step)+','+yk+')', 10);
}
function start()
{
if(done) return
done = 1;
if(navigator.appName=="Netscape") {
document.napis.left=innerWidth/2 - 145;
anim(60,innerHeight - 60)
}
else {
napis.style.left=280;
anim(60,document.body.offsetHeight - 60)
}
}
//-->
</script>
<div id="napis"
style="position: absolute; top: 159px; width: 400px; height: 78px; left: 215px"><font size="5"><b>欢迎您的到来!</b></font></div>
<script language="JavaScript">
<!--
setTimeout('start()',10);
//-->
</script>
</body>
</html>
转载于:https://blog.51cto.com/chunzhisu/1536792