  
- UID
- 133
- 帖子
- 51
- 精华
- 1
- 积分
- 186
- 金币
- 55
- 威望
- 2
- 贡献
- 0

|
网页之多变的滚动字幕特效
<script language="JavaScript">9 W) K9 {8 S7 R' m3 b
# N# R3 ~+ @$ f9 W" s<!-- ActiveASCII by Neal Kanodia (please, don't delete this line)
* @( P& z, {$ Y9 T! G9 x7 |" ^
8 I! l( C. T+ ]# Z3 afunction createArr(num) { for(var i = 0; i < num; i++) { this = null } }" [0 ^# B; E' |) p4 x* h
function fillArr(tx,me,ti,wa) { this.text = tx; this.method = me.toLowerCase(); this.ticks = ti; this.wait = wa }
! g- w9 g4 o5 t' V' G' o: ~ bfunction block(num,txt,mthod,tcks,wit) { blocks[num] = new fillArr(txt,mthod,tcks,wit) }
* }: J" l3 V' j& y3 Nfunction ms(unt) { var sp = ""; for( var i = 1; i <= unt; i++ ) { sp += " " } return(sp) }( c. k3 T& s! g+ E" p
function Activate() { if (cblock == max) { cblock = 0; if (iloop == 0) { loops--; if (loops == 0) { meth = "0" } else { meth = blocks[cblock].method } } else { meth = blocks[cblock].method } } else { meth = blocks[cblock].method }
! t! w. {, V# m2 hif (meth == "0") { document.Active.ASCII.value = end }
4 ^7 n3 e! x i- L( R- j! W! H8 o- Z; ^if (meth == "display") { Tape = blocks[cblock].text; Wait = blocks[cblock].wait; Display() }9 J7 v1 c( n: }; v6 O
if (meth == "display center") { Tape = blocks[cblock].text; Wait = blocks[cblock].wait; half = Tape.length / 2; DisplayC() }
6 M) O$ d) g- q$ Cif (meth == "scroll left") { clen = tlen; Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; tTicks = Ticks * 2; ScrollL() } O: N$ k/ B% ^% }
if (meth == "scroll right") { clen = 0 - blocks[cblock].text.length; Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; tTicks = Ticks * 2; ScrollR() }% j' k+ m8 |4 @& [
if (meth == "scroll lc") { clen = 0 - blocks[cblock].text.length; Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; Wait = blocks[cblock].wait; tTicks = Ticks * 2; half = Tape.length / 2; ScrollLC() }$ g+ J9 E& S* \4 P/ [
if (meth == "scroll rc") { clen = tlen; Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; Wait = blocks[cblock].wait; tTicks = Ticks * 2; half = Tape.length / 2; ScrollRC() }
, n7 H [1 @% W: Hif (meth == "scroll cl") { Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; tTicks = Ticks * 2; half = Tape.length / 2; clen = cent - half; ScrollCL() }
! e4 h( m+ [4 B3 x7 _3 Y) J0 Tif (meth == "scroll cr") { Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; tTicks = Ticks * 2; half = Tape.length / 2; clen = cent - half; ScrollCR() }' @/ \% L; @/ \1 n; x4 o+ u- g
if (meth == "slide left") { Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; Wait = blocks[cblock].wait; cpos = 0; clet = Tape.charAt(cpos); clen = tlen; cstr = ""; SlideL() }
1 R! B' E' B& s& u; I8 s+ Sif (meth == "slide lc") { Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; Wait = blocks[cblock].wait; cpos = Tape.length - 1; clet = Tape.charAt(cpos); clen = 0; cstr = ""; half = Tape.length / 2; iba = cent - half; ib = ms(iba); SlideLC() }3 f% g2 V y% v: m: a# V
if (meth == "slide rc") { Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; Wait = blocks[cblock].wait; cpos = 0; clet = Tape.charAt(cpos); cstr = ""; half = Tape.length / 2; clen = cent + half; fs = ms(cent - half); SlideRC() }
: M4 ?& p: y2 I) P) zif (meth == "slide cl") { Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; cpos = 0; clet = Tape.charAt(cpos); cstr = Tape.substring(1,Tape.length); half = Tape.length / 2; clen = cent - half; iba = 0; ib = ms(iba); SlideCL() }
' T" L/ ]/ z# p; _if (meth == "slide cr") { Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; cpos = Tape.length - 1; clet = Tape.charAt(cpos); cstr = Tape.substring(0,Tape.length - 1); half = Tape.length / 2; clen = 0; fs = ms(cent - half); SlideCR() }
' Z; R2 V% M" m& c, F6 \if (meth == "slip left") { clen = 0; Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; SlipL() }
; _3 @3 H) o+ F" z' X% P8 [' mif (meth == "slip right") { clen = 0; Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; SlipR() }& \; o" H0 @* F: ^" k
if (meth == "slip letter") { Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; cpos = Tape.length - 1; clet = Tape.charAt(cpos); cstr = Tape.substring(0,Tape.length - 1); clen = 0; SlipLet() }1 _& X) H' }4 O: K0 X
if (meth == "split"){ Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; var iii = Tape.length / 2; if (iii / 2 != Math.ceil(iii / 2)) { Tape = Tape + " " } hstr1 = Tape.substring(0,Tape.length/2); hstr2 = Tape.substring(Tape.length/2,Tape.length); tTicks = Ticks * 2; clen = cent - hstr1.length; iba = 0; ib = ms(iba); Split() }9 z& v' g* D1 f9 L, N
if (meth == "merge"){ Tape = blocks[cblock].text; Ticks = blocks[cblock].ticks; var iii = Tape.length / 2; if (iii / 2 != Math.ceil(iii / 2)) { Tape = Tape + " " } hstr1 = Tape.substring(0,Tape.length/2); hstr2 = Tape.substring(Tape.length/2,Tape.length); tTicks = Ticks * 2; clen = 0 - hstr1.length; iba = tlen; ib = ms(iba); Wait = blocks[cblock].wait; Merge() } }/ Q; L- ?) O) k
function Display() { document.Active.ASCII.value = Tape; cblock++; timerID = setTimeout("Activate()",Wait) }
, i9 M B" s6 {8 G+ N J) Efunction DisplayC() { var temp = cent - half; ini = ms(temp); document.Active.ASCII.value = ini + Tape; cblock++; timerID = setTimeout("Activate()",Wait) }* n5 k- y5 S$ ~% ?, F
function ScrollL() { if (clen >= 0) { ini = ms(clen); tickered = ini + Tape; document.Active.ASCII.value = tickered; clen--; timerID = setTimeout("ScrollL()",Ticks) } else { beg = 0 - clen; if (beg == Tape.length) { document.Active.ASCII.value = ""; cblock++; timerID = setTimeout("Activate()",Ticks) } else { tickered = Tape.substring(beg,tlen); document.Active.ASCII.value = tickered; clen--; timerID = setTimeout("ScrollL()",tTicks) } } }
`* G- L, c' b) t$ B/ A! ufunction ScrollR() { if (clen >= 0) { if (clen > tlen) { document.Active.ASCII.value = ""; cblock++; timerID = setTimeout("Activate()",Ticks) } else { ini = ms(clen); tickered = ini + Tape; document.Active.ASCII.value = tickered; clen++; timerID = setTimeout("ScrollR()",Ticks) } } else { beg = 0 - clen; tickered = Tape.substring(beg,tlen); document.Active.ASCII.value = tickered; clen++; timerID = setTimeout("ScrollR()",tTicks) } }% p( u/ b5 |( ?: z& ]0 T2 Z, } F
function ScrollLC() { if (clen >= 0) { if (cent <= (clen + half)) { cblock++; timerID = setTimeout("Activate()",Wait) } else { ini = ms(clen); tickered = ini + Tape; document.Active.ASCII.value = tickered; clen++; timerID = setTimeout("ScrollLC()",Ticks) } } else { beg = 0 - clen; if (cent <= (clen + half)) { cblock++; timerID = setTimeout("Activate()",Wait) } else { tickered = Tape.substring(beg,tlen); document.Active.ASCII.value = tickered; clen++; timerID = setTimeout("ScrollLC()",tTicks) } } }6 ]5 T! ^7 Q0 a4 e" e# [- q
function ScrollRC() { if (clen >= 0) { if (cent >= (clen + half)) { cblock++; timerID = setTimeout("Activate()",Wait) } else { ini = ms(clen); tickered = ini + Tape; document.Active.ASCII.value = tickered; clen--; timerID = setTimeout("ScrollRC()",Ticks) } } else { beg = 0 - clen; if (cent >= (clen + half)) { cblock++; timerID = setTimeout("Activate()",Wait) } tickered = Tape.substring(beg,tlen); document.Active.ASCII.value = tickered; clen--; timerID = setTimeout("ScrollRC()",tTicks) } }: E* g" s5 v1 i9 U; U* q
function ScrollCL() { if (clen >= 0) { ini = ms(clen); tickered = ini + Tape; document.Active.ASCII.value = tickered; clen--; timerID = setTimeout("ScrollCL()",Ticks) } else { beg = 0 - clen; if (beg >= Tape.length) { document.Active.ASCII.value = ""; cblock++; timerID = setTimeout("Activate()",Wait) } else { tickered = Tape.substring(beg,tlen); document.Active.ASCII.value = tickered; clen--; timerID = setTimeout("ScrollCL()",tTicks) } } }) O: ]( e9 a( ^' }# V
function ScrollCR() { if (clen >= 0) { if (clen > tlen) { document.Active.ASCII.value = ""; cblock++; timerID = setTimeout("Activate()",Wait) } else { ini = ms(clen); tickered = ini + Tape; document.Active.ASCII.value = tickered; clen++; timerID = setTimeout("ScrollCR()",Ticks) } } else { beg = 0 - clen; tickered = Tape.substring(beg,tlen); document.Active.ASCII.value = tickered; clen++; timerID = setTimeout("ScrollCR()",tTicks) } }
# B6 @- P. q& ?# Z+ \function SlideL() { if (clen >= 0) { ini = ms(clen); tickered = cstr + ini + clet; document.Active.ASCII.value = tickered; clen -= 3; timerID = setTimeout("SlideL()",Ticks) } else { document.Active.ASCII.value = cstr + clet; cstr = document.Active.ASCII.value; clen = tlen - cstr.length; cpos++; clet = Tape.charAt(cpos); if (clet == " ") { cstr = cstr + " "; cpos++; clet = Tape.charAt(cpos) } if (clet == "") { cblock++; timerID = setTimeout("Activate()",Wait) } else { timerID = setTimeout("SlideL()",Ticks) } } }6 ~2 P! X$ u% v
function SlideLC() { if (clen <= cent - half) { ini = ms(clen); tickered = ini + clet + ib + cstr; document.Active.ASCII.value = tickered; clen += 3; iba -= 3; ib = ms(iba); timerID = setTimeout("SlideLC()",Ticks) } else { iba = cent - half; ini = ms(iba); ib = ms(iba); document.Active.ASCII.value = ini + clet + cstr; cstr = clet + cstr; clen = 0; cpos--; if (cpos >= 0) { clet = Tape.charAt(cpos); if (clet == " ") { cstr = " " + cstr; cpos--; clet = Tape.charAt(cpos) } timerID = setTimeout("SlideLC()",Ticks) } else { cblock++; timerID = setTimeout("Activate()",Wait) } } }2 \" g- W' O$ w4 J! G+ U
function SlideRC() { if (clen >= 0) { ini = ms(clen); tickered = fs + cstr + ini + clet; document.Active.ASCII.value = tickered; clen -= 3; timerID = setTimeout("SlideRC()",Ticks) } else { clen = cent + half; cstr += clet; document.Active.ASCII.value = fs + cstr; cpos++; clet = Tape.charAt(cpos); if (clet == " ") { cstr = cstr + " "; cpos++; clet = Tape.charAt(cpos) } if (clet == "") { document.Active.ASCII.value = fs + Tape; cblock++; timerID = setTimeout("Activate()",Wait) } else { timerID = setTimeout("SlideRC()",Ticks) } } }
4 D* U! L! L6 {+ c; Y- efunction SlideCL() { if (clen > 0) { ini = ms(clen); tickered = ini + clet + ib + cstr; document.Active.ASCII.value = tickered; clen -= 3; iba += 3; ib = ms(iba); timerID = setTimeout("SlideCL()",Ticks) } else { iba = 0; ib = ms(iba); clen = cent - half; ini = ms(clen); document.Active.ASCII.value = ini + cstr; cstr = cstr.substring(1,Tape.length); cpos++; clet = Tape.charAt(cpos); if (clet == " ") { cstr = cstr.substring(1,Tape.length); cpos++; clet = Tape.charAt(cpos) } if (clet == "") { document.Active.ASCII.value = ""; cblock++; timerID = setTimeout("Activate()",Ticks) } else { timerID = setTimeout("SlideCL()",Ticks) } } }
6 ~. k4 K- c2 j8 kfunction SlideCR() { if (clen <= cent + half) { ini = ms(clen); tickered = fs + cstr + ini + clet; document.Active.ASCII.value = tickered; clen += 3; timerID = setTimeout("SlideCR()",Ticks) } else { clen = 0; document.Active.ASCII.value = fs + cstr; cstr = cstr.substring(0,cstr.length - 1); cpos--; half += 1; if (cpos >= 0) { ; clet = Tape.charAt(cpos); if (clet == " ") { cstr = cstr.substring(0,cstr.length - 1); cpos--; clet = Tape.charAt(cpos) } timerID = setTimeout("SlideCR()",Ticks) } else { cblock++; timerID = setTimeout("Activate()",Ticks) } } }9 j7 U' s7 G' d5 a& Y6 R
function SlipR() { if (clen >= 0) { if (clen > tlen) { document.Active.ASCII.value = ""; cblock++; timerID = setTimeout("Activate()",Ticks) } else { ini = ms(clen); tickered = ini + Tape; document.Active.ASCII.value = tickered; clen++; timerID = setTimeout("SlipR()",Ticks) } } else { beg = 0 - clen; tickered = Tape.substring(beg,tlen); document.Active.ASCII.value = tickered; clen++; timerID = setTimeout("SlipR()",Ticks) } }1 O: x7 J$ D* P" p) s$ T- U3 S
function SlipL() { if (clen >= 0) { ini = ms(clen); tickered = ini + Tape; document.Active.ASCII.value = tickered; clen--; timerID = setTimeout("SlipL()",Ticks) } else { beg = 0 - clen; if (beg == Tape.length) { document.Active.ASCII.value = ""; cblock++; timerID = setTimeout("Activate()",Ticks) } else { tickered = Tape.substring(beg,tlen); document.Active.ASCII.value = tickered; clen--; timerID = setTimeout("SlipL()",Ticks) } } }# T# y. t: i4 K
function SlipLet() { if (clen < tlen) { ini = ms(clen); tickered = cstr + ini + clet; document.Active.ASCII.value = tickered; clen += 3; timerID = setTimeout("SlipLet()",Ticks) } else { clen = 0; cstr = cstr.substring(0,cstr.length - 1); cpos--; if (cpos >= 0) { ; clet = Tape.charAt(cpos); if (clet == " ") { cstr = cstr.substring(0,cstr.length - 1); cpos--; clet = Tape.charAt(cpos) } timerID = setTimeout("SlipLet()",Ticks) } else { cblock++; timerID = setTimeout("Activate()",Ticks) } } }: Z2 Y- U3 c1 @& S
function Split() { if (clen >= 0) { ini = ms(clen); tickered = ini + hstr1 + ib + hstr2; document.Active.ASCII.value = tickered; clen--; iba += 2; ib = ms(iba); timerID = setTimeout("Split()",Ticks) } else { if (clen <= 0 - hstr1.length) { cblock++; timerID = setTimeout("Activate()",Ticks) } else { beg = 0 - clen; tickered = hstr1.substring(beg,tlen); document.Active.ASCII.value = tickered + ib + hstr2; clen--; iba += 2; ib = ms(iba); timerID = setTimeout("Split()",tTicks) } } }
" ~5 z7 B- Q; q+ ?% x8 _ gfunction Merge() { if (clen >= 0) { if (clen > cent - hstr1.length) { tickered = ini + hstr1 + hstr2; document.Active.ASCII.value = tickered; cblock++; timerID = setTimeout("Activate()",Wait) } else { ini = ms(clen); tickered = ini + hstr1 + ib + hstr2; document.Active.ASCII.value = tickered; clen++; iba -= 2; ib = ms(iba); timerID = setTimeout("Merge()",Ticks) } } else { beg = 0 - clen; tickered = hstr1.substring(beg,tlen); document.Active.ASCII.value = tickered + ib + hstr2; clen++; iba -= 4; ib = ms(iba); timerID = setTimeout("Merge()",tTicks) } }% F" |" J9 C/ e# b" D, t1 q; `
2 ~" T) W$ f% e( u2 q///////////////////////////////////////////////////////////////// d w2 S- l( J: ~7 [. e5 u& y
//# User Vars- C( a/ ] o; p2 R/ w5 t
// Number of blocks (see bottom) to be displayed.* t, D: v u" N& J
// ***COMMON ERROR***: Make sure to set this value according to the2 j7 b% @# X+ P
// number of blocks (always the last block # + 1)!
6 h7 J' i/ p, `6 i9 y+ Y# qvar max = 18
. i5 }( X2 s' w* q9 A
7 ?0 Q/ ]0 N) f2 \/ M// Don't change this!
% p, ?, g5 F3 u8 u" p- p) svar blocks = new createArr(max)
1 u0 S9 O d$ [6 W2 U. H: l) i/ e) I8 S a% q
// Length of textbox
Q; _% z8 p& n3 i( D/ ~. y5 b// ***COMMON ERROR: If you change this or the length of the
( `- m& C) m9 N// textbox, remember to change the other accordingly.***
: |5 g( a: S; e- C6 T0 d* mvar len = 50
' s" y/ t8 w% v9 {4 h3 I9 L E( B# _0 G, Z$ g5 M
// Number of time to loop ALL blocks (use 0 for unlimited)
9 c4 \$ Q" L6 U' H1 {* j+ _/ @# K ~var loops = 0 R. u3 c x' l( v2 ^
, z6 _' v" Z) _// If you set the number of loops, set the final messege4 w. O3 f' n6 l8 p" `
var end = 'End of "ActiveASCII" by Neal Kanodia.'! F& r. n0 k, x1 X8 w& ?0 N
, J4 s3 q5 s5 W p X// Use this format for each string (starting at 0 until 1 less4 H- {" \: Q6 D# O" {4 o% Y) v
// than max):- W6 _9 {. U" ]8 ^& W- @
// block(#block,"Text to display","Method",#ticks,#wait)
# O& ]7 A+ t# A& j; F3 D g// example: block(0,"1st block.","Scroll Left",25,0)* Y. z+ T3 r" ]
// ***COMMON ERROR***: If you add a block INCREASE MAX BY 1
( `9 e9 M. ?: E, s/ h, b3 Z" `" v! S8 w// ***COMMON ERROR***: If you remove a block DECREASE MAX BY 1
1 L% ]3 X+ ]5 l" n' p1 h// ***COMMON ERROR***: Check the spelling of your methods!!!
9 v$ }% h8 J$ ?3 M3 Wblock(17,"欢迎光临七色风!","display",0,500)
, ?5 C: t; L6 }block(18,"新一代网络商城!","display center",0,500)
, W8 w# ?/ I; g: Fblock(2,"新一代企业信息系统!","scroll left",25,0)
( A$ y, k2 T9 D9 c' [! ?2 t, P9 ~block(3,"全新的自助建站模式!","scroll right",25,0)
. x+ ~1 h' f9 c9 ], ]5 yblock(4,"欢迎光临七色风!","scroll lc",25,500)
( z% ~* i3 {; a% I4 fblock(5,"欢迎光临!","scroll rc",25,500)
^& ^; J/ V# |1 x1 bblock(6,"欢迎光临!","scroll cl",25,0)4 g; I3 d3 F& x9 u$ f
block(7,"欢迎光临!","scroll cr",25,0)
1 {8 Q1 n4 Y, c1 ~' l1 V7 q. J# Gblock(8,"欢迎光临!","slide left",25,500)
/ |# c" e" o& [block(9,"欢迎光临!","slide lc",25,500)
; L1 S# L9 @6 M2 ]block(10,"欢迎光临!","slide rc",25,500)% W7 y& w/ o& Q1 @/ A( Z/ F
block(11,"欢迎光临!","slide cl",25,0)
: m( S' p" b) m+ R8 Sblock(12,"国内域名:110元!","slide cr",25,0)
7 E9 o P+ B- ~" l. T: dblock(13,"国际域名:58元!","slip left",25,0)1 t6 Y# ?/ G; k( U
block(14,"欢迎光临中讯数据!","slip right",25,0)
: T' G4 g! M, f, N, g1 _block(15,"欢迎您的光临","slip letter",25,0)
, x/ U' `1 P" Sblock(16,"","display",0,500)
& t ~0 K9 ^$ Y( |block(0,"欢迎欢迎!","merge",25,1000)
2 A1 s* }2 c' z& [; q) hblock(1,"欢迎!","split",25,0)
! ?& ]5 [( h: U0 w8 S//End User Vars" w7 {% ~- d. K! Q* O$ S
/////////////////////////////////////////////////////////////////
) m0 p( S ^. g4 P, t9 Y% ~, D9 J: I, j! Q$ S* T% J7 |! B5 J- p
// Don't change!!!! L4 u9 B1 H9 G" |3 G
var tlen = 2.4 * len+ }/ o2 h9 Q1 \# t* a
var cent = tlen / 2.27 F q9 [, a# t6 U, v% {
var clen = null
! s* U& u1 x V5 ? G0 \var tickered = null! t. x& M# G% |
var ini = null. D$ S! `) r3 v
var iloop = 08 y: t& h6 h# L* \, H
if (loops == 0) {iloop = 1}& l, Y2 z1 P, S! |
var cblock = 07 H1 [& U6 d+ B/ X) K$ r: n3 H
var timerID = null/ O s1 y+ Y3 t
var beg = null' p4 P* ~/ E4 q) S/ ^
var clet = null
; r/ Z0 w! ?4 m, }/ Qvar cstr = null m4 h1 e0 x, | y" a6 _! y7 i$ ]
var cpos = null
( J* }7 a( J; b2 qvar ib = null# [& _# S' M+ F* K3 z" r6 @
var iba = null/ r3 ]7 |3 _" d. G( u
var fs = null
2 Y) ^; N; M4 k1 r' \- Yvar hstr1 = null' |5 \$ G5 H7 d# r% I \; Q
var hstr2 = null
9 A8 I, I8 F1 {, k5 V<!-- end -->( d8 R$ D) k7 u5 C- h
7 u( ^$ F! I: z0 K</script># i$ Q$ P) ^$ K* }
<script language="JavaScript">
3 x& n+ Y; h4 I7 ^/ _2 t<!--
! \" J4 {4 L* e7 o5 o7 ]/ ~$ odocument.write('<form name="Active" onSubmit="0">')
/ Z) u+ ^4 e+ _: K2 I8 W( Zdocument.write('<input type="text" name="ASCII" size="50">')
6 u0 |: J* ^2 E9 jdocument.write('</form>')
: u h8 e: v4 `4 kActivate()7 V0 U1 n6 F- T3 D. \: a8 C
<!-- end -->3 G2 X5 z ^8 U- H8 [
0 q" h4 D! ?2 ^3 R- s9 l& c( L</script> |
|