29.htm
来自「介绍了javascript的常用的函数」· HTM 代码 · 共 31 行
HTM
31 行
<html>
<head>
<title>文字来回反弹</title>
<script language="javascript">
<!--
i=0;
control = true;
function moveText(){
screenWidth = parseInt(document.body.clientWidth);
textWidth = parseInt(txt.style.width);
txt.style.left = i;
if(control && screenWidth-textWidth > i){
i+=2;
}else{
control = false;
}
if(!control && i > 0){
i-=2;
}else{
control = true;
}
setTimeout("moveText()",1);
}
//-->
</script>
</head>
<body onLoad="moveText()">
<div id="txt" style="position:absolute;width=98">文字来回反弹</div>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?