文字显示效果

 

点击这里看效果


在 <body> 与 </body> 之间加入:

<script language="JavaScript">

IE4 = navigator.appName ==
"Microsoft Internet Explorer"
&& parseInt(navigator.appVersion) >= 4;
NS4 = navigator.appName.substring(0,8) ==
"Netscape" && parseInt(navigator.appVersion) >= 4;

function checkBrowser(){
if(IE4 || NS4){
return true;
}
return false;
}

function movableObj(startX, startY, endX, endY,
delay, speed, refId){
this.sX = startX; this.sY = startY;
this.eX = endX;
this.eY = endY; this.de = delay;
this.sp = speed;
this.ref = refId;
xL = endX - startX;
yL = endY - startY;
with (Math){
if(abs(xL) > abs(yL)){
this.xS = (xL > 0)?1:-1;
this.yS = (yL > 0)?abs(yL / xL):-abs(yL / xL);
this.howManySteps = abs(xL / speed);
} else if(abs(yL) > abs(xL)){
this.yS = (yL > 0)?1:-1;
this.xS = (xL > 0)?abs(xL / yL):-abs(xL / yL);
this.howManySteps = abs(yL / speed);
} else {
this.yS = (yL > 0)?1:-1;
this.xS = (xL > 0)?1:-1;
this.howManySteps = abs(xL / speed);
}
}
this.startMovement = startMovement;
}

// startMovement() -- starts the movement

function startMovement(){
if(checkBrowser()){
if(IE4){
ref = document.all(this.ref).style;
} else {
ref = document[this.ref];
}
doDynamicMovement(this.sX, this.sY, this.eX, this.eY,
this.de, this.xS, this.yS, ref, this.sp, this.howManySteps);
}
}

// doDynamicMovement() -- does the Dynamic Movement

function doDynamicMovement(curX, curY, eX, eY, sp, xS, yS, ref, speed, hS){
if(Math.floor(hS - 1) != 0){
hS--;
curX += xS * speed;
curY += yS * speed;
ref.left = Math.round(curX);
ref.top = Math.round(curY);
setTimeout("doDynamicMovement(" + curX + ", " + curY + ", " + eX + ", " + eY + ", " + sp + ", " + xS + ", " + yS + ", ref, " + speed + ", " + hS + ")", sp);
} else {
setPos(eX, eY, ref);
}
}

// setPos() -- sets the end position accurately when doDynamicMovement has done its job

function setPos(x, y, ref){
ref.left = x;
ref.top = y;
}
</script>

<SCRIPT LANGUAGE="JavaScript">
dynaText = new movableObj(-100,-100,80,180,10,10,"wow");
</SCRIPT>

<div id="wow" style="position: absolute;
left: -100; top: -100; width: 300;font-size: 18pt">
<p> 欢迎光临一迪网络! </p></div>

<form>
<input type="button" onClick="dynaText.startMovement()"
value="按下去看看" name="button">
</form>