返回列表 发帖

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

<style type="text/css">
1 ~- y3 r& M. [, X#supertext {. x4 ~2 y/ n' S* Y
position:absolute;
! a  n; N+ @/ U4 H  wleft:0;
/ J% [& `: _, W- v  d! Mtop:0;
: O" J( `4 n7 M' L* Q9 J9 \: u* Lvisibility:hide;$ `# u7 n  `) d6 Z& Z
visibility:hidden;: ?' B, t; z8 _- Z1 b% A/ w- q
}
$ u* E; ~( g2 Y/ S  [</style>3 b: J& j& v# F$ U( i9 z
<script language="JavaScript1.2">$ ^/ o( k8 O" F: T3 T  |
<!-- 改变下的字体的大小。颜色-->8 I; m; k; ?% W( R) H9 }# ~
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 {  _( v9 t! H# u, @- {+ l* V' qvar hidetimer='';* i, x( r  v/ P, J: S
<!-- 改变下的弹跳速度-->
5 I1 \( K0 t" P0 r/ Qvar BallSpeed = 20;
5 y' G/ S$ m8 k: A# Wvar contentWidth;
6 B+ U! u" z& B& Vvar contentHeight;% |3 ^, M% o2 A" k' P
var maxBallSpeed = 50;
7 `1 B, m9 ^; M$ `: P# @$ J! O" u  c1 h! o5 @0 b+ M2 O
9 K, }' M4 l$ L
var xMax;- Z% ?  R* i# g2 r
var yMax;
6 \( U7 w; s, B) Dvar xPos = 0;
5 ^( g* E4 i  w5 a7 k0 X& m( zvar yPos = 0;7 _) o2 e* m9 y7 C. o2 x
var xDir = 'right';
0 {9 z, E+ L& q+ N+ }5 Evar yDir = 'down';
/ n9 m6 l; k! Zvar superballRunning = true;2 I; T" M: R% @0 k
var tempBallSpeed;3 t$ }# P+ A! J; Y. ~; Z
var currentBallSrc;
1 l0 t! }$ V9 \5 [0 D* |3 ^var newXDir;1 [# L$ y7 G# ^4 K! l& x) C& W
var newYDir;4 T% d9 p0 _; h  g. ^

4 f' K; N9 w6 J/ Dfunction initializeBall() {# c8 g* P. W' q" h! o! ]
   if (document.all) {
$ I& S2 Y. J7 J0 k/ c, t. x; G      xMax = document.body.clientWidth
* ?7 S- Z& y* i. h2 ~% s! Q. I      yMax = document.body.clientHeight; K1 _' z1 P/ L0 j- B
      document.all("supertext").style.visibility = "visible";( W, Z0 s. H4 |  i5 D
      contentWidth=supertext.offsetWidth  S/ _- h$ ~, `9 @$ E) b0 N* }
      contentHeight=supertext.offsetHeight
* F$ V$ E/ f7 A      }
- R+ R: u; m- q; u' u, P   else if (document.layers) {+ U8 L# |9 U5 ~) U2 J, M; ~
      xMax = window.innerWidth;. D- R; u+ C- m" R+ A6 W& q% g
      yMax = window.innerHeight;* _' f+ a5 o3 Y% _
      contentWidth=document.supertext.document.width
* H$ ~: k- S. K2 l! S      contentHeight=document.supertext.document.height
' _) d# v% M+ f      document.layers["supertext"].visibility = "show";  N) R# A+ ]# H: K
      }
, F0 u; i7 m- j' v) d* p   setTimeout('moveBall()',400);0 u( ^. m4 w+ L  L! F
   if (hidetimer!='')
0 f# Y3 ~) b! z$ ?. S& W   setTimeout("hidetext()",hidetimer)" `, S6 W- s. I
   }3 G. w  _) w; b; t: e8 a7 ]- o6 r

3 L2 g2 i4 h  l6 c" O, c1 Yfunction moveBall() {
* N- ?: s4 T) s7 ~1 y   if (superballRunning == true) {8 j: l% i- }; k2 p
      calculatePosition();
, S' I! s! q) d      if (document.all) {. ?* I1 {. Q; e6 g8 G4 v
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
+ `8 I+ N2 z- \) l4 q         document.all("supertext").style.top = yPos + document.body.scrollTop;$ U" [/ T( H- A- m1 a4 [/ L; {
         }
/ @' [, h1 N, C- L8 b- F4 c- s* e      else if (document.layers) {
# _% i! l* l( U. {# |* o         document.layers["supertext"].left = xPos + pageXOffset;
% i; e+ u. ~0 z; M- l5 o7 Z         document.layers["supertext"].top = yPos + pageYOffset;
+ c4 U$ l9 i, w( q         }( B8 n& g9 ?$ N: Q
      animatetext=setTimeout('moveBall()',20);' }) X6 l$ |, K! C) C8 y
      }
8 B3 q* R7 L3 V% k  g   }( s/ y4 Y7 o& R5 @2 z4 P# z" M
" k+ j* t) L& {, s% u* z/ T
function calculatePosition() {% G! W0 S* C3 |9 Q6 m& e* Z
   if (xDir == "right") {9 X- H( i) B1 L! u' N; N
      if (xPos > (xMax - contentWidth - BallSpeed)) {
6 q, e6 h. W. D3 y. _5 L         xDir = "left";% V9 `! Q2 R. P0 G
         }5 G  ~$ A6 `/ C% K- o* d- S/ {
      }/ U5 s5 K- p% d7 m. P
   else if (xDir == "left") {! [. h* ?# y" m0 P- V
      if (xPos < (0 + BallSpeed)) {
2 ~3 p" W9 }* X         xDir = "right";
; Q  f- n' b2 B+ [$ m" C         }
. T$ O$ L" h) y; L  F      }4 F: ^/ F: u) p; v2 M2 w
   if (yDir == "down") {: n& d( j8 }" l) N" y
      if (yPos > (yMax - contentHeight - BallSpeed)) {
* F% y3 q% R' j, T& J7 R% L         yDir = "up";
/ K1 W9 Z/ D& r! P$ l         }# u- T. B+ s3 X+ X
      }6 h" |& Y/ v: J1 R6 o( O3 F+ n7 Q2 k
   else if (yDir == "up") {
: w6 n# F' m+ K' p' X& B. D; v* K      if (yPos < (0 + BallSpeed)) {
; u/ V9 z, E. o) s6 d$ a         yDir = "down";7 a4 v% S- L" M7 E: @
         }3 v: M2 |3 ^1 y; B- J$ t, k
      }
+ d- `' \- `. p! \) `   if (xDir == "right") {
0 a( K" ?8 t; j( [/ N" e. Z7 `      xPos = xPos + BallSpeed;
" ?  A( ?4 N! p) k5 p; @      }
( C/ x  I0 x& e- q5 _& U! u( q# p% ~& D   else if (xDir == "left") {1 [5 Q$ N: x. P* X2 _
      xPos = xPos - BallSpeed;* S& P; s, B* b& W
      }
+ h) D9 Q! ?  t2 O   else {
1 B6 \; X0 Q4 [1 S$ ]- O# h5 Z      xPos = xPos;0 w& X# P  ]$ N" k7 w8 L( ^
      }
' ], [/ y  j& C( ]' S+ S! X' a   if (yDir == "down") {& }+ L2 R8 z7 y( B" t# [
      yPos = yPos + BallSpeed;
- K4 g1 p" Z, j. f9 {7 t9 H      }
$ n; z7 _# ~+ D+ u   else if (yDir == "up") {
. f7 d' _2 a2 n2 {1 O+ \      yPos = yPos - BallSpeed;
" o7 P3 Y4 _5 u( ?) N      }, h7 @5 d- Y, {6 Q
   else {6 K. W, a1 h# d- |
      yPos = yPos;
9 Z& u* ^1 @! q' D      }7 x5 }: o4 `6 R( x
   }
% S  o- U/ u1 i2 t& @2 f/ a" ]: Q/ m
function hidetext(){/ _( ], K3 [3 o  e& W  j( D/ t
if (document.all)
: n0 g! b8 |1 [: A6 Fsupertext.style.visibility="hidden"
4 x( {+ V7 `, c+ P, m( zelse if (document.layers)
* }+ k* f+ p$ Qdocument.supertext.visibility="hide"
6 ~. L$ I! v5 y5 [/ j7 KclearTimeout(animatetext); |0 y/ A! G6 K$ V- p
}
! E/ z: L2 m8 H% @4 {# O' \: }5 j+ [& V5 e8 D9 Z; X6 O8 c
if (document.all||document.layers){
- g( I, s; S) |2 ldocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" n$ Q# |8 ?2 G3 [" r7 |window.onload = initializeBall;7 X3 L& k2 F+ A
window.onresize = new Function("window.location.reload()");; L# Z' W& ^6 Z9 ]+ ?
}
2 I' {! V; c3 k% ]3 w( h! V7 X* s
0 O* b6 I: m& ~% R7 c* I$ H</script>

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