返回列表 发帖

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

<style type="text/css">
" @3 ~1 d; h( K5 K) C; k#supertext {9 q% `0 z+ a4 a3 ^
position:absolute;8 ?6 s5 @7 z9 X7 O  ^! e$ o- a2 q% u5 ]
left:0;- o! P$ D8 m& B" f9 X
top:0;) D' ~3 d" d; ^" ~6 ?3 R* ~  B; A
visibility:hide;7 k2 [$ d2 ^; D! G
visibility:hidden;
# E" K& e/ f! m9 q" w! x}
, h; l5 U9 V- V. Q2 j9 R</style>
7 h" J0 t& t( N$ X: a<script language="JavaScript1.2">
6 m& E% ]' I% h6 q<!-- 改变下的字体的大小。颜色-->
" w. U/ `9 ], mvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
. n: M/ r9 |4 x$ ^; k- c+ O  r* a% cvar hidetimer='';" H) D, d. b7 i& p& U3 m6 L
<!-- 改变下的弹跳速度-->1 u: M" D6 W% `  K8 f
var BallSpeed = 20;6 Z8 @- f7 L: \1 F  A/ u
var contentWidth;6 Z! f- p# w" J8 k0 h, _
var contentHeight;
' d. m& E, p. K' svar maxBallSpeed = 50;8 `$ T2 R1 k+ T- g  n
2 Y. k4 _5 Q# C, F  @
- k7 L' g1 d8 B  Z! y' ~* a
var xMax;
" W/ X" ?# u2 b) F* `var yMax;! y3 F3 \5 X8 n' n% ]
var xPos = 0;, K/ ^0 g* [0 x1 g# F6 I- E0 R* ]
var yPos = 0;
$ j( M' U3 K0 `4 a4 Avar xDir = 'right';
3 |- D4 l" G3 ^. ^var yDir = 'down';! I% k2 g, z7 n% R+ d% t9 F/ W
var superballRunning = true;/ \' l7 W( Y) ~5 |  @: T" h
var tempBallSpeed;
' `0 [4 @2 V  i6 ~5 O: n9 X/ u; Avar currentBallSrc;
& V( l# S( J2 j2 C9 gvar newXDir;
: P& T/ ?( B6 vvar newYDir;6 _+ x9 m) P4 M9 \7 ?/ g$ M5 m7 X8 H

  d6 W' K5 k% {; u  N( I" Ufunction initializeBall() {% C. r/ p' S2 O- A! x
   if (document.all) {( O& r3 }! a$ _( r+ j( O! X1 o
      xMax = document.body.clientWidth/ t8 g8 P" L* A
      yMax = document.body.clientHeight
. j/ k9 n% f' J& q      document.all("supertext").style.visibility = "visible";" P" S# ]( r+ @, {( t/ k+ ?6 n1 Q
      contentWidth=supertext.offsetWidth& {. k5 [0 t! g) R
      contentHeight=supertext.offsetHeight! g4 u5 `+ ~: w" k0 y! B
      }
% K6 s7 x0 P. }8 o9 \* Y8 q   else if (document.layers) {
3 G# x1 N9 C9 k/ L6 h" s      xMax = window.innerWidth;
. @1 V0 O9 G  O, v+ ?0 F/ q: y      yMax = window.innerHeight;8 U& y* I* N$ I+ }% T( C0 t
      contentWidth=document.supertext.document.width
$ u0 u7 ]; @5 n+ J6 ~      contentHeight=document.supertext.document.height
, {9 @6 m) o. \      document.layers["supertext"].visibility = "show";7 H* w4 I+ n1 r% ^
      }
: m. B8 h  u4 W3 z   setTimeout('moveBall()',400);
8 @- t( m  o1 s: v! h+ E   if (hidetimer!='')# `( ~. h; Y' R' U. `- A8 c& f
   setTimeout("hidetext()",hidetimer)
4 f. W4 N! v) {# X   }5 H+ y. n1 P2 D0 k" b7 W

2 i" w+ K( k1 H- S- Rfunction moveBall() {
) |: Q/ Z) u/ m: M3 t9 x6 \! ^# T# J1 k   if (superballRunning == true) {8 ^2 D; A9 t& R) }% M+ O
      calculatePosition();
8 J1 O/ _  ]* ]1 E) u      if (document.all) {/ l/ j) z% z( K# x5 O
         document.all("supertext").style.left = xPos + document.body.scrollLeft;5 }- ?" _# G- I0 d! g' {+ y$ _
         document.all("supertext").style.top = yPos + document.body.scrollTop;, D: \2 A: J  A1 V% O! F& y4 g# u
         }. _, m% Q9 o; x" o9 D1 @. _
      else if (document.layers) {8 T; r2 Z$ K) u, ~& s% w9 I* [
         document.layers["supertext"].left = xPos + pageXOffset;; T7 l5 I1 d' Y* x
         document.layers["supertext"].top = yPos + pageYOffset;
2 x: b, K' A( `. P, [         }/ d- H4 r- W7 L* h1 a
      animatetext=setTimeout('moveBall()',20);
2 V1 C' E$ L; W$ W+ D* i' K      }
* k' ^+ Q# a! L   }
) c; y5 u! k8 O1 _' W* R6 e/ O# g$ @0 q
function calculatePosition() {
# r  @( k4 o5 u2 O- N   if (xDir == "right") {
/ p# e$ h1 d) E  t9 [4 v6 ]5 t5 {  M) }      if (xPos > (xMax - contentWidth - BallSpeed)) {" y) y7 V2 ^3 r; g
         xDir = "left";
; c/ a1 b2 G1 |& G5 X9 W% _  G         }
) C% ?# }6 j; j; O+ C6 j9 _      }
1 t( W$ ]4 _% n   else if (xDir == "left") {9 }# J1 \5 G- x- A
      if (xPos < (0 + BallSpeed)) {
2 A$ V+ I9 r4 b3 P8 Z( C         xDir = "right";$ e* g3 {) I& v* o' Y) f
         }+ |* W4 w0 S6 K
      }
' R5 K5 @" n& p9 {   if (yDir == "down") {, C5 G' H; p# b5 k6 i9 _) X
      if (yPos > (yMax - contentHeight - BallSpeed)) {
6 s" y3 s0 r/ _' p( q8 s' W         yDir = "up";
& ]+ ^6 S+ h, O  Y1 d9 @. b! Z8 B         }
! \7 K3 S  k' x      }
: z% ~1 M6 I% }, k   else if (yDir == "up") {- }/ E8 Y3 P8 q+ }' R
      if (yPos < (0 + BallSpeed)) {- Y! V7 ^+ C2 o/ B3 S% Z
         yDir = "down";
$ y" ?4 G4 i3 b2 q, _/ i         }. y4 @. x6 H; ^  g2 a
      }
; y1 ~) F4 z# \. ?   if (xDir == "right") {1 k! w0 q& B) a( D0 `0 [2 N0 |
      xPos = xPos + BallSpeed;
2 U; D% L% ^0 T1 `8 g      }
& A; n2 E& u7 g4 D% P5 |  B   else if (xDir == "left") {7 ?: S8 M6 k* ^8 a$ ]& n. i
      xPos = xPos - BallSpeed;4 J0 z8 n; I, ]
      }& H7 W+ a4 P) X8 t. ~1 B& Y8 r
   else {
% N1 s9 {- X6 C( X1 E3 d      xPos = xPos;* h' [- l! C- r# ?: b
      }
; q( l6 T0 X9 f  p6 T9 ]   if (yDir == "down") {
, I3 Q8 n6 I5 d      yPos = yPos + BallSpeed;3 w/ Q8 Y9 i! q" N4 i
      }
. r: T5 [4 j/ I3 F2 S; N   else if (yDir == "up") {
7 p6 V7 r4 c; r5 d7 H8 j' z8 U3 {" _      yPos = yPos - BallSpeed;
. W6 L/ {- S% d: r. }      }+ L$ a9 A6 B- T  ?* l
   else {
8 h2 T6 D+ j$ J. `1 e      yPos = yPos;
' W5 l2 a3 d2 ~! U4 e      }
* S+ G+ c& J! S5 |5 U   }
* y5 o( C/ D, k  B
" \+ @+ [* n! i9 c/ `function hidetext(){
: k: T) Y7 U  I# ~& K: Xif (document.all)
! }; `: M% N6 isupertext.style.visibility="hidden"# f: r: w3 A% D6 s
else if (document.layers)  T; d, h' h# P4 g1 F2 ]
document.supertext.visibility="hide"
% X4 S; o$ U7 j% y5 `. Q- FclearTimeout(animatetext)
3 R7 f; N& W) U7 j}7 J1 F8 o6 I7 V

9 N5 f- R: V0 l! q' wif (document.all||document.layers){; G; T! C0 M4 R2 t. W0 B. E
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
2 H  y- y( J$ J  M0 Dwindow.onload = initializeBall;# m7 ?& b! _* T
window.onresize = new Function("window.location.reload()");
' E, b2 |- D8 Q/ Q, e}
) Y! C( X! _) Z- w
7 r5 \  Y4 x5 I0 ~& E# F7 O</script>

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