-1

我有网络应用程序我想执行文本效果,就像我们在电源点中的线条来自左侧一样,我尝试了很多链接但没有得到

<HTML>
<Body>

 <p>This is the First Ans Last Game Of
 <p>The Tournament
</Body>
<HTML>

Javascript

function lib_bwcheck() {
    this.ver = navigator.appVersion;
    this.agent = navigator.userAgent;
    this.dom = document.getElementById ? 1 : 0;
    this.opera5 = this.agent.indexOf("Opera 5") > -1;
    this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom && !this.opera5) ? 1 : 0;
    this.ie6 = (this.ver.indexOf("MSIE 6") > -1 && this.dom && !this.opera5) ? 1 : 0;
    this.ie4 = (document.all && !this.dom && !this.opera5) ? 1 : 0;
    this.ie = this.ie4 || this.ie5 || this.ie6;
    this.mac = this.agent.indexOf("Mac") > -1;
    this.ns6 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
    this.ns4 = (document.layers && !this.dom) ? 1 : 0;
    this.bw = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);
    return this;
}
var bw = new lib_bwcheck()
var px = bw.ns4 || window.opera ? "" : "px";

function run() {
    var cx, cy, a, css, obj, nest, ooo;
    if ((document.all) && (!bw.opera5)) {
        movy = document.body.clientHeight - 64;
        movx = document.body.clientWidth - 50;
    } else {
        movx = window.innerWidth - 50;
        movy = window.innerHeight - 64;
    }
    for (var i = 0; i < maxitems; i++) {
        cx = Math.round(ox + i * syto / (maxitems - 1));
        if (ys[i] == 0) ys[i] = Math.round(Math.random() * syto + syto);
        //  if (ys[i]==0)    ys[i] = Math.round(Math.random()*100);
        if (cx > sxto || cx < sxfrom) {
            if (cx > sxto) cy = syfrom + (ys[i] - syfrom) * (cx - sxto) / (110 - sxto);
            else cy = syfrom + (ys[i] - syfrom) * (sxfrom - cx) / (sxfrom);
        } else {
            ys[i] = 0;
            cy = syfrom + Math.sin((cx - sxfrom) * Math.PI * yspeed / (sxto - sxfrom)) * ((cx - sxfrom) * (sdto - sdfrom) / (sxto - sxfrom) + sdfrom);
        }
        cx = Math.round(cx * movx / 100);
        cy = Math.round(cy * movy / 100);
        if (bw.ns4) {
            ooo = eval("document.s" + i);
            if (cx >= movx || cx <= 0) {
                ooo.visibility = "hidden";
                cx = 0;
            } else ooo.visibility = "visible";
            ooo.moveTo(cx, cy);
        } else {
            obj = "s" + i;
            nest = "";
            css = bw.dom ? document.getElementById(obj).style : bw.ie4 ? document.all[obj].style : bw.ns4 ? eval(nest + "document.layers." + obj) : 0;
            if (cx >= movx || cx <= 0) {
                css.visibility = "hidden";
                cx = 0;
            } else css.visibility = "visible";
            css.left = cx;
            css.top = cy;
        }
    }
    ox -= xspeed;
    if (ox < -syto) ox = 100;
    setTimeout("run()", tpause, "JavaScript");
}

var sxfrom = 20;
var sxto = 80;
var syfrom = 50;
var syto = 30;
var sdfrom = 20;
var sdto = 30;
var yspeed = 3;
var xspeed = 1;
var pcol = Number(255).toString(16);
var tpause = 20;
var schar = "JavaScriptSource";

var fontface = 0;
var fontsize = "6";
if (fontface == 0) fontface = 'Arial, Helvetica, sans-serif';
else if (fontface == 1) fontface = 'Times New Roman, serif';
else if (fontface == 2) fontface = 'Courier New, Courier, mono';
else if (fontface == 3) fontface = 'Georgia, Times New Roman, Times, serif';
else fontface = 'Verdana, Arial, Helvetica, sans-serif';

var maxitems = schar.length;
var t = 0;
t = pcol.length;
for (var i = 0; i < 6 - t; i++) pcol = '0' + pcol;

if ((document.all) && (!bw.opera5)) {
    movy = document.body.clientHeight - 64;
    movx = document.body.clientWidth - 50;
} else {
    movx = window.innerWidth - 50;
    movy = window.innerHeight - 64;
}

var ox = 100;
ys = new Array();
for (var i = 0; i < maxitems; i++) {
    if (bw.ns4) document.writeln("<layer id='s" + i + "'>");
    else document.writeln("<div id='s" + i + "' style='position:absolute; z-index:3;'>");
    document.writeln('<font color=#' + pcol + ' face="' + fontface + '" size="' + fontsize + '">' + schar.substr(i, 1) + '</font>');
    if (bw.ns4) document.writeln("</layer>");
    else document.writeln("</div>");
    ys[i] = 0;
}

setTimeout("run()", tpause, "JavaScript");​



//DO NOT MODIFY
 /*
 <APPLETINFO>
 appletname=jswavetext
 applettype=JAVASCRIPT
 created=1049050369870
 appletfilename=jswavetext1.js
 </APPLETINFO>
 <JAVASCRIPT>
  fontsize=6
  sxfrom=20
  sxto=80
  syfrom=50
  syto=30
  sdfrom=20
  sdto=30
  yspeed=3
  xspeed=1
  tpause=20
  schar=JSWaveText
  fontface=0
  pcol=255
  </JAVASCRIPT>
  <HTMLGENERATOR>
null</HTMLGENERATOR>
 */
4

1 回答 1

1

您复制的代码很古老。我会看看CSS 过渡来帮助你做到这一点。如果您在动画上使用延迟选项,您可以通过添加一个具有新位置的类来触发它,

于 2012-04-18T06:42:31.713 回答