返回列表 发帖

网页之不断弹射的文字-特效

<style type="text/css">- Q  \2 P4 h% m: s+ x
#supertext {# f+ \% Y  y& m0 k5 l% L1 f
position:absolute;; l, O9 }) g, r
left:0;3 \  V- k7 T7 p, e! p7 Z8 u
top:0;
2 {: Z3 U# A0 Y* J% Nvisibility:hide;
0 r' R' ?! @% I0 ^0 Ivisibility:hidden;* z: Y. ?! ^$ W9 x! O1 W
}
/ d9 Z+ F+ l; Z; z6 A# t</style>
( I0 H4 B+ B  b6 \; B9 K<script language="JavaScript1.2">
7 |( P( f% e3 v4 ^' p7 \, t<!-- 改变下的字体的大小。颜色-->) e* m6 z- J. F9 |8 v- y& z5 d! \: f
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'1 w3 m) W2 u7 O* B6 {+ N- b" t9 L
var hidetimer='';8 y7 m" ~7 \5 U9 I. U
<!-- 改变下的弹跳速度-->
# J( A1 G; n$ @* C8 S+ Qvar BallSpeed = 20;6 Y+ Q. \* M. Q; ~, _8 S
var contentWidth;- ?6 `) c0 R% D& b7 q+ g4 O' c
var contentHeight;
6 Q: q# e' u* }0 e: _var maxBallSpeed = 50;7 K. n( W9 t1 ~- [  ^3 H' l! E
5 O! ~) {5 C7 d
- d5 h4 ?) R' m+ N% G+ I' x( e
var xMax;
" I2 w* V) O) A8 X4 {8 Xvar yMax;
/ ], J" @2 Y! Qvar xPos = 0;
  o8 A; z. n6 n. s8 G5 y& l& ivar yPos = 0;8 s8 p, F/ l8 W! t
var xDir = 'right';" m! o! \$ o6 G) H9 X
var yDir = 'down';* y- }# R: R( M9 C
var superballRunning = true;/ J7 t2 j, j+ D" J: X
var tempBallSpeed;
# q: g9 o6 W8 h# z, ^( c$ L7 qvar currentBallSrc;" s# d; p" q+ X4 w3 L
var newXDir;& k6 @+ }4 H4 _
var newYDir;9 S, X7 o# w7 j' L2 ^5 e  w/ i

/ p: @* \2 o4 wfunction initializeBall() {
% T& M* N, p& Q+ P. R6 h! B   if (document.all) {2 l6 V0 T! _; }8 ^0 ^
      xMax = document.body.clientWidth
* D7 q% i& E; G. k      yMax = document.body.clientHeight
/ [, f$ \, A" j      document.all("supertext").style.visibility = "visible";
& M8 i. I( ~5 O/ n+ e- U  L& h      contentWidth=supertext.offsetWidth: K' X! I0 m: C& @8 o5 T
      contentHeight=supertext.offsetHeight
: n* j* z6 x( v      }+ m; ~5 i6 ^. ?5 H% `
   else if (document.layers) {7 o" e+ n6 a" P
      xMax = window.innerWidth;3 k, `2 ?1 T1 Z0 o7 S# f/ ?4 z3 a
      yMax = window.innerHeight;: R2 `2 A8 }6 v* n- \( N8 n% b
      contentWidth=document.supertext.document.width+ g3 ^% V( V, \; t; r9 [5 p
      contentHeight=document.supertext.document.height- C$ [* X: o6 b0 \" @% Q
      document.layers["supertext"].visibility = "show";
0 A8 M  s$ z" w/ K7 k$ k: V- T      }
5 n9 r) G0 L' u: Y   setTimeout('moveBall()',400);% q# y' |5 M. L! \" e, {
   if (hidetimer!='')
$ e$ T- Z% a6 ~  a! O- [, w   setTimeout("hidetext()",hidetimer)
) `( V0 W/ D, F! P7 l   }# v+ f$ k1 p) T7 Z, c
+ K* x0 N, Y9 P) i3 h: E. b) k
function moveBall() {! R& B- O* e; A
   if (superballRunning == true) {
2 f) A+ G+ e; |* X) O' `4 T      calculatePosition();
: I4 j9 u  T5 E* v4 h8 |      if (document.all) {* n* x& e$ ?+ ^
         document.all("supertext").style.left = xPos + document.body.scrollLeft;- H  O5 l8 d) m( K+ q+ b6 [
         document.all("supertext").style.top = yPos + document.body.scrollTop;
/ b$ b" b5 R+ [3 f( h/ J- k4 p2 k& v         }
" u2 \/ n; R2 w& v      else if (document.layers) {: U, G9 u9 }9 t. f5 j+ j6 S
         document.layers["supertext"].left = xPos + pageXOffset;
* |. ?; g5 M2 O, X9 A0 i3 x         document.layers["supertext"].top = yPos + pageYOffset;5 I( {. R' X1 ~2 R0 r
         }# W: X' P8 k( q: m
      animatetext=setTimeout('moveBall()',20);
7 ~$ a, i  u; Z! l2 N5 _& w      }; c0 Z9 h# N1 }3 o
   }+ Y% H) Q7 O% d% M0 k( N

  S) G9 l9 I1 ~& ^, x+ k1 L" t8 qfunction calculatePosition() {
( K: x  [4 ]) |: V, O3 `# c   if (xDir == "right") {
% d% H) v/ @' E" `( E  p, D      if (xPos > (xMax - contentWidth - BallSpeed)) {
- N7 [4 O+ N3 V- S1 F, z         xDir = "left";
7 B1 i: W- D4 M" M) k         }1 q3 Y$ P% R/ j+ q% n4 n" I
      }
+ f$ t5 G, {; G& f   else if (xDir == "left") {
) V4 @- j5 D  V" c* f      if (xPos < (0 + BallSpeed)) {# f  p/ C" I7 l2 A
         xDir = "right";- Q: ]0 ~3 [% X9 j
         }1 g8 ]. b% E4 B
      }0 o1 e- A8 ]; l/ X
   if (yDir == "down") {% v) i1 v% c0 o- o' x5 |  f
      if (yPos > (yMax - contentHeight - BallSpeed)) {
- d7 K) x1 |. |$ }0 C% T5 O% [6 [         yDir = "up";0 |& R4 `- S- N& v
         }
: j0 r) {1 Z; P; H& W      }
7 E0 n% X5 d5 ]   else if (yDir == "up") {, ^# {* x* {1 }* p$ j
      if (yPos < (0 + BallSpeed)) {* O, E, J' z; V  @
         yDir = "down";& T, u5 H+ A0 u+ }
         }3 O" v6 i' m& o9 `" L
      }
( ^" T2 I+ s1 K8 c7 R- }   if (xDir == "right") {! j- |1 w; J8 O% q
      xPos = xPos + BallSpeed;
) n/ \* _* e. W& O! P3 G3 D      }. G! c- E: u# y! M4 n  ?
   else if (xDir == "left") {
+ ~& L& G: G" z5 H9 f: {! }, J      xPos = xPos - BallSpeed;
: k* r2 r( ~! m; k4 [: ~, D      }, x! t# z8 w/ m/ q/ K
   else {
6 V+ a0 ^7 P0 a1 V; k, ?      xPos = xPos;8 \$ M5 X5 o. ]9 b, l  ]
      }
4 x  j, Q7 }+ U; J( I, P) L; R1 X7 t   if (yDir == "down") {
0 `, w/ ~, h3 O$ j$ N1 \# B      yPos = yPos + BallSpeed;
/ `4 @/ c# v3 |, W      }
& n% f0 F6 Z/ O, ~   else if (yDir == "up") {
  K4 b) M9 r/ L* J  E7 D8 ]      yPos = yPos - BallSpeed;/ z( E6 ^3 b5 }8 D* J2 W8 y
      }& f: B' w" H1 @: h9 m: a
   else {7 j1 u3 S3 P* z9 w% ~# m6 \
      yPos = yPos;
+ m/ {9 E+ E1 X4 Z3 l: W3 f  I' [      }6 O3 e: T* \, Z) G( Z6 v
   }! P& q3 D$ P7 F% [3 F
# G+ Y4 a; L4 G; g% _0 Z- c3 m; s8 r
function hidetext(){' j% B+ Q; C2 [. ^. b. L
if (document.all)
4 Q/ S* n1 {7 Msupertext.style.visibility="hidden"$ f9 h( }1 F- }2 ~+ C% P
else if (document.layers)* o+ \' L# h% [: ]
document.supertext.visibility="hide", ?" t0 S4 z% w% P  z* u2 T
clearTimeout(animatetext)2 E/ ?- {# v- ?) y2 f- T" i5 I( P
}
3 ?" J- z7 B. }0 }0 |/ c7 g+ l! C, S0 d4 H. F
if (document.all||document.layers){" I: E1 B6 n. X
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 w5 ]) S; [( I! ]
window.onload = initializeBall;
, {, C! j2 O7 ~7 U* f+ {2 }  n! dwindow.onresize = new Function("window.location.reload()");
3 L5 {; X& P) D  o}4 C$ R3 m# P7 g* h5 G1 G7 ~
. Y3 b* t4 a0 a, E) E2 q
</script>

返回列表
【捌玖网络】已经运行: