8-7.htm

来自「JScript网页特效,包含很多的实现网页特效的方法.」· HTM 代码 · 共 80 行

HTM
80
字号
<html>
<head>
<title>§8.7 伴随鼠标左右的跳动文字</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<script language=javascript>
<!--
var chx=0;
var chy=0;
var val=0;
function locatexy()
{
  chx=window.event.x;
  chy=window.event.y;
}
document.onmousemove=locatexy;
function follow(i)
{
  var x;
  if(i<4) x=chx-60+i*12;
  else x=chx-30+i*12;
  var y=chy-20+Math.floor(Math.random()*40);
  w=eval("word"+i);
  with(w.style)
  {
    left=x.toString()+"px";
    top=y.toString()+"px";
  }
}

function show(i)
{
  var w=eval("word"+i);
  with(w.style)
  {
    visibility="visible";
    s=parseInt(fontSize);
    if(s>=200) s-=100;
    else 
      if(s>90&&s<=100)
      {
        s-=85;
        clearInterval(val);
        if(i<7) val=setInterval("show("+(i+1)+")",20);
      }
    fontSize=s;
   }
}

function start()
{
  val=setInterval("show(1)",20);
  for(i=1;i<=7;i++)
  {
    setInterval("follow("+i+")",100);
  }
}

//-->
</script>

<script language=javascript>
var word=new Array(7);
word[1]="欢";
word[2]="迎";
word[3]="光";
word[4]="临";
word[5]="本";
word[6]="站";
word[7]="!";
for(i=1;i<=7;i++)
document.write("<div id='word"+i+"' style='width:20px;height:20px;position:absolute;font-size:1000;visibility:hidden'><font face='Forte' color='#cc0000'>"+word[i]+"</font></div>");
start();
</script>

</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?