返回列表 发帖

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

<style type="text/css">
- s! i$ z) a+ Q$ e- m#supertext {- e  L% [& T% F
position:absolute;
, R7 R% D# L, o, E2 Jleft:0;
/ w+ [+ X7 w; p& \: n7 P, ktop:0;. T/ T% P6 z6 c& ^3 R2 M
visibility:hide;
3 X: I: m7 c/ z6 C: \visibility:hidden;
0 {8 J8 e) U0 V, Z7 n. n}
9 A( Z! g- }' e8 R</style>
% T2 T) D& A2 b0 W* z<script language="JavaScript1.2">
4 Z2 D: z+ ]6 c, f6 J# W<!-- 改变下的字体的大小。颜色-->
% x5 @/ e* n2 l6 {  e7 A; C% Cvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
, k% O. V0 X" z1 n# p: A$ s% c, Jvar hidetimer='';
( w% a' N4 J' N' ^<!-- 改变下的弹跳速度-->
. m+ a4 w8 U( W) K' V2 @- q# ~3 ovar BallSpeed = 20;
# d5 I$ Q1 m. p4 K0 D" dvar contentWidth;, A' |1 J) P4 f) u. U3 V: m9 g0 P
var contentHeight;
! m( I/ Q  H# E' h( q- {var maxBallSpeed = 50;
' J- n6 G. U6 a$ H# V5 q8 d, F/ K& v5 q! x8 Z

3 c; a) n7 ~7 _6 W! Dvar xMax;
- B& R& p& m6 Rvar yMax;) `* R+ V8 l: i/ `( j
var xPos = 0;
. j/ }% F1 n( ^7 r0 ?! r9 F6 j; u4 mvar yPos = 0;
7 z  b8 D5 J- }& K# g( b3 Xvar xDir = 'right';
* G5 O6 d5 g7 H  @4 m; @9 Evar yDir = 'down';! }" ~* i5 ^3 m* }6 G
var superballRunning = true;
, H7 @" k: X* p4 [  [& g7 N, Gvar tempBallSpeed;: t2 @8 W- Q$ J- Y" i) X
var currentBallSrc;
- M3 i) ?7 _; p7 |var newXDir;7 g2 B+ s, ^& ?) n! N
var newYDir;
6 _* `: \, f- t* E( E& S; G: P
6 W. F/ N- }, j( u2 Z4 K- C; u5 L7 Jfunction initializeBall() {
4 d& L2 v2 ]% Y2 T   if (document.all) {
3 U/ ]; T1 {% e- `      xMax = document.body.clientWidth
' a9 p5 v( O+ t# k# [      yMax = document.body.clientHeight' S! E! R1 {' e; F, p2 G6 \0 K
      document.all("supertext").style.visibility = "visible";% l# ]5 n# \8 l! o
      contentWidth=supertext.offsetWidth
( I2 \. V6 J7 i+ A% e      contentHeight=supertext.offsetHeight
$ u0 ~1 B, d2 K  g9 y) d7 m0 P0 u& x      }+ ]# ], O# q( M: n6 H
   else if (document.layers) {
# f! n. m& k" s5 a+ H      xMax = window.innerWidth;
3 T; A6 i! g6 w. D& d- _5 C      yMax = window.innerHeight;
7 m& y- W$ ]0 U4 a4 E' K) P      contentWidth=document.supertext.document.width0 i. R; b; O% P$ e
      contentHeight=document.supertext.document.height
5 b$ T+ N% p6 V! B5 T' R* C      document.layers["supertext"].visibility = "show";$ X7 d. Q* H2 W; H- {' O
      }
/ o  L: H( }1 L* ?% |. w   setTimeout('moveBall()',400);
$ X9 i' K0 h& U! W- O' U0 B7 R   if (hidetimer!=''). s5 G$ s0 g) S' U9 B( ?
   setTimeout("hidetext()",hidetimer), u' [% W# i0 s% |& [! }# n
   }  V/ w7 j: u* @0 s7 a$ l7 v- w
9 h4 e- a7 J* }/ d) w$ d4 J
function moveBall() {/ q5 H* v" S# C, `" ^) o% @' E" K
   if (superballRunning == true) {/ q$ P/ g! p/ G+ D( I$ c
      calculatePosition();9 I" b3 [; \* \/ u+ }4 ?0 D
      if (document.all) {
5 j0 `) T9 {0 Y         document.all("supertext").style.left = xPos + document.body.scrollLeft;
- \# i+ H* c% S         document.all("supertext").style.top = yPos + document.body.scrollTop;, U4 `8 B- Q1 x7 w
         }$ Y( ~. T6 q% u9 G9 \: f
      else if (document.layers) {& ^  G5 d/ ~% E& L+ J( d. d
         document.layers["supertext"].left = xPos + pageXOffset;
; i- h4 e6 r  I5 w% E         document.layers["supertext"].top = yPos + pageYOffset;% O' o% z  ~! O, E% ~  z
         }
! D9 b- d1 X# j, f- g+ k0 |      animatetext=setTimeout('moveBall()',20);  n& S1 x$ ?( S- y& N
      }2 V, U) o: e& o' S! h9 k
   }9 @* _( m$ m( n6 x
( V* p5 X/ i9 a1 k
function calculatePosition() {
9 V+ f# E( Q4 P3 V. D   if (xDir == "right") {& F6 }$ ^3 ~  U" h# u
      if (xPos > (xMax - contentWidth - BallSpeed)) {
2 n. f/ c) ~4 T1 R. T2 c: {         xDir = "left";
# n! s9 z* C/ Y; @2 ]         }
( u# y5 Q5 _  V$ y! I, V& p0 }* C      }
1 D% Y' b" O9 S4 [% _   else if (xDir == "left") {6 B8 i/ C" A# U+ C2 u, [& N- I
      if (xPos < (0 + BallSpeed)) {
2 U; ]/ S( `7 K! n/ B         xDir = "right";9 ]- y5 f4 `" B5 B% ^$ X
         }( R2 X. C& p9 t. N6 n6 k' e9 l: R4 ^
      }3 U' ^+ b5 s7 U% M( O; y
   if (yDir == "down") {4 {8 {7 i* V1 d" C  y
      if (yPos > (yMax - contentHeight - BallSpeed)) {  H" ~6 M% e& |) ?% I: d% W3 M
         yDir = "up";
# T& p! f+ A- e$ x         }8 \, g; R1 b2 Z; |4 ], ~: h; ~
      }" f) K! Z. D+ t: t
   else if (yDir == "up") {
4 j6 _6 G7 W" n1 C      if (yPos < (0 + BallSpeed)) {
- h. l* c3 Q5 q6 V8 a         yDir = "down";8 s6 ~6 @( C( ~& u: U, I( {
         }* o# K1 D4 Q9 M5 B; o
      }: q; t1 {& Q+ x; R& I
   if (xDir == "right") {
3 s2 ~' c* }( e9 _      xPos = xPos + BallSpeed;
; |0 w$ |- }; r$ \+ v3 I      }
! J5 @: y* H, b- }$ o) q- E6 X( o+ m   else if (xDir == "left") {
, z+ i2 M, m  B( M0 R/ A# S5 f      xPos = xPos - BallSpeed;5 g# j$ }, a+ g3 t
      }: Z" g" a3 P/ {$ B: p" \$ }/ M
   else {
$ `7 r/ W' {7 }6 X- e) X      xPos = xPos;. P  [4 R, y9 _' P
      }
" Z5 j+ H" _* W* u" ^, Q   if (yDir == "down") {( R% N$ d8 e0 H7 _! K
      yPos = yPos + BallSpeed;
0 ]1 ]2 ^( `1 u      }
1 B7 |7 F7 Y0 G) n: ^5 i; T   else if (yDir == "up") {' {. D% x' U" H( H
      yPos = yPos - BallSpeed;
% r( f+ t+ h: W7 D* f      }
9 x8 {  I. K8 z5 w4 s   else {
$ v# G' x7 p! j, {! d$ Z      yPos = yPos;) j; {: T( k2 G! }# v* v1 H) a
      }7 x0 N3 ]. }* a  N1 H$ E
   }
5 P# Y1 u! C+ ^" k2 p3 }
) `# x6 g+ E" q8 Zfunction hidetext(){
" f$ a- h; }8 [3 P! Q! r5 Sif (document.all)3 o* [# [! C& B5 K3 q
supertext.style.visibility="hidden"9 f1 O6 ?. h0 B2 A# U
else if (document.layers)
. [+ N& s9 `* Q, ]  O3 A- ddocument.supertext.visibility="hide"7 {# V- |9 F9 s9 N: @, r$ @
clearTimeout(animatetext)
( f8 n' S  J3 Z( y}/ E' o# }. b% U9 h3 b

. F; x% [" B$ I: `: ]if (document.all||document.layers){
% y4 Z$ g; h# f2 ^document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')8 p) y. ]9 e* U$ y: ^3 @4 h- J6 W. D
window.onload = initializeBall;
- ^/ k, P1 @* d9 u1 f# H5 E) Wwindow.onresize = new Function("window.location.reload()");
4 H. J& C8 y0 ?1 @}, d) v5 S1 w7 t) D1 h3 q# r3 X
1 k5 u- S2 Y" b5 H9 x  \
</script>

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