返回列表 发帖

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

<style type="text/css">
; N! z8 [1 N; Q#supertext {4 G) A4 F) q8 d2 L
position:absolute;
' w+ ?1 c3 |$ T. _& a* lleft:0;
0 C( ^3 o" ?; vtop:0;1 I8 \3 }5 Z" q0 l; c3 Z8 x$ F
visibility:hide;
% o- y. g! Q4 N  o) p8 R% E5 G& ^visibility:hidden;, q) L0 t/ N: X. h2 k+ c  @/ y+ Z1 D
}5 k5 D' @( c& X
</style>
: S$ _- F/ z* I* b7 C) ~. a  V% R<script language="JavaScript1.2">6 E2 v0 G$ D7 R* o4 Z: s
<!-- 改变下的字体的大小。颜色-->' ?' z/ W& ]! K1 Z: |
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'1 j* o  ?  `: S5 s& {' |8 q
var hidetimer='';% k9 S4 @" O" Y$ l! S) I
<!-- 改变下的弹跳速度-->$ A9 L9 F( g9 p: G
var BallSpeed = 20;
1 ]; y+ x$ E0 x: }* \0 wvar contentWidth;# k0 I' C7 D/ h! j. M
var contentHeight;
8 u+ C  |. T5 Q% ?' W3 ovar maxBallSpeed = 50;3 }/ Z. L( @- M2 O+ {( k
- d% _& _1 J, k" p% m3 ?$ L, P
+ P$ ]4 G3 L% d
var xMax;
1 c( T. }  P3 R) |/ `  ivar yMax;
- u% E" w& q! S; a/ zvar xPos = 0;2 M. j3 z. ~( c5 d5 z
var yPos = 0;$ y" l, a, P% S( V, l/ B% S
var xDir = 'right';
* }! J7 Y0 [* ~3 Hvar yDir = 'down';
% {; v( X4 n4 H+ ~var superballRunning = true;, s# M( ?2 H# X3 |% Y; E6 F
var tempBallSpeed;
# a& Y0 ~) @& u3 C# Nvar currentBallSrc;/ R% V% l7 q+ `" |. W  _
var newXDir;2 T) k* U& g: _6 j6 v* i
var newYDir;! K1 N8 H: [& @, y: G7 o
. M; H: N4 J# X
function initializeBall() {
, e. [4 h7 e6 O. s+ V0 p) h   if (document.all) {
- X: C1 F& M% M, |; H3 p- k      xMax = document.body.clientWidth
8 A9 g6 w) Q; U/ j+ N& l      yMax = document.body.clientHeight1 F0 a9 J+ L8 J; E# {
      document.all("supertext").style.visibility = "visible";
7 I: `5 J/ c3 Y. d      contentWidth=supertext.offsetWidth4 ^3 v9 m9 I5 E: t5 n9 g, N
      contentHeight=supertext.offsetHeight
5 Q$ U8 |1 G% P, e( S7 S      }
0 {, Y$ V) I. K) j* N1 q" E% K: Q   else if (document.layers) {
3 r1 q" {' o& [) @      xMax = window.innerWidth;2 s1 C; }& |6 ^3 |* S) C0 H+ _, @
      yMax = window.innerHeight;/ E# t$ W7 s, k& i6 ]
      contentWidth=document.supertext.document.width
$ O! h7 m% X; b1 M9 f$ ]      contentHeight=document.supertext.document.height
1 q7 T' Z( ~+ I% H/ K! Z      document.layers["supertext"].visibility = "show";
; ?7 r# d) L8 \* H/ Z( `' i( o      }
0 }2 y6 N# h8 g5 \, [% \1 x   setTimeout('moveBall()',400);
8 H  C- u# J: X3 f- u0 s; @% w   if (hidetimer!='')
# X2 V5 `  _2 U7 P   setTimeout("hidetext()",hidetimer)# ~1 l4 ~6 L: p& Z  b/ d
   }- o% f2 R7 |9 [4 I

; _; [( a  x3 _/ T3 g/ Nfunction moveBall() {
* T2 \' w! C$ s" e   if (superballRunning == true) {; t( x( Z& U& u- Y
      calculatePosition();5 O$ Z! u3 q, z# e4 q8 c: }
      if (document.all) {
/ p& e' x4 V% D& ]9 X- R: X         document.all("supertext").style.left = xPos + document.body.scrollLeft;
7 x) s4 E" x/ N4 w; S! j         document.all("supertext").style.top = yPos + document.body.scrollTop;
1 s5 ?! K0 q6 A' b) D7 ]0 m         }& ~/ k2 j' d' `/ c- w/ B: s
      else if (document.layers) {4 x: b) x; ^0 ?  `5 }
         document.layers["supertext"].left = xPos + pageXOffset;7 }  ]/ B, ?/ O) q# g, X5 \
         document.layers["supertext"].top = yPos + pageYOffset;  ~( _3 ]. `. V% h1 r6 C, v5 z
         }
+ [) i) V  R' B      animatetext=setTimeout('moveBall()',20);0 e* [2 Y* y/ y2 @' x$ h
      }  R. F! g4 O: P) M$ i: T
   }
9 I& Q& L& }- j/ o6 a8 v' X! o# _- Z9 G; e  T1 U4 U
function calculatePosition() {
  l6 h8 q" _( ~" v3 k  r   if (xDir == "right") {
; y8 y$ _6 O! F6 G8 f9 J      if (xPos > (xMax - contentWidth - BallSpeed)) {( E  R: S# L5 W" r+ N
         xDir = "left";# |2 F" Q- b* w% m' ^* N( W7 v
         }2 _$ D" n6 w( Y3 \" T
      }
) {/ J# Y+ t  t5 H0 p4 [   else if (xDir == "left") {+ }0 N* Z  q, P. @, ^: {2 \$ Y
      if (xPos < (0 + BallSpeed)) {
0 T2 s3 g' Y% c, {         xDir = "right";
" z4 \+ a: d' K( f4 U         }2 g4 l  M$ h- {' \" c
      }
" g* j& a9 G* p. N7 g   if (yDir == "down") {$ [- ?7 {' z5 Y6 P
      if (yPos > (yMax - contentHeight - BallSpeed)) {* D6 \1 A# z3 D# N1 [% P
         yDir = "up";
' v! N' f% |* h: a, A' y. m& D/ ]. P         }3 @: e/ Y! f  @7 g) R3 o# m
      }% Z! ]6 E. w0 E7 ~9 T, v) i
   else if (yDir == "up") {! [8 V: t  m7 g& J0 K& T. h* ~
      if (yPos < (0 + BallSpeed)) {
: Z- B0 g/ o- Q% a         yDir = "down";' ^; W( t: g& h# I8 L3 X* E$ ^% ^
         }1 A2 a8 ?/ `7 l' ^5 m2 S- x
      }3 t. y! g2 y+ c5 z* c
   if (xDir == "right") {
+ e! j! ]+ u& b( t* N      xPos = xPos + BallSpeed;; \1 ?. i- n3 c
      }) ~$ D4 v# j8 x% t; }
   else if (xDir == "left") {* Q2 C  `1 [* i, l7 g
      xPos = xPos - BallSpeed;- J4 u  ]/ h( V3 y3 w, `: [
      }
: v# q$ z9 C% }) S# u! t' n: K   else {. Z1 w  X! y: I7 ?! E3 a1 H- d1 C
      xPos = xPos;
+ ?: r+ s9 j! P' \2 m, M9 |) _      }
! {' j" L3 s" ?. S. {) l% h' l   if (yDir == "down") {' D6 {' |7 |# T; _
      yPos = yPos + BallSpeed;
& ]) H0 r! L! S5 F1 N) r      }. K) I% J, P) N7 y) N, G
   else if (yDir == "up") {
0 m( r. l0 M- a( F      yPos = yPos - BallSpeed;
% o& B7 D  H8 y+ u      }9 Z5 S5 S: T* [$ N6 Q" U! g- M1 [" v
   else {8 b0 t" _3 M' `) _' V
      yPos = yPos;
$ B" L( t- s( M3 K* r9 r' x      }
$ G' n; @6 c! z8 @   }; Z- w9 P. T$ w( X
" l0 s6 t9 K1 ?6 K' p! X, p8 X
function hidetext(){' {+ [% k# z, V, y# O
if (document.all)
0 x* N; {% y# Esupertext.style.visibility="hidden"/ E! f: R$ g4 y' A0 {: n. ?6 W  z: [
else if (document.layers)
% h) e9 l1 r* W' Bdocument.supertext.visibility="hide"; R+ h0 q1 k6 j0 r, f0 E; a# \
clearTimeout(animatetext)( E8 a. B' R$ h0 C' b
}
6 S8 P1 y4 `' b$ z5 l
: `+ }7 c1 C; [. t" g9 ^if (document.all||document.layers){! i  n' _- i9 X  X' |" f
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 b% G$ f6 O/ A8 B  Wwindow.onload = initializeBall;
! G; \$ y( G5 c$ dwindow.onresize = new Function("window.location.reload()");
" J& V: l- ?; x# Y}) y, x  m- _  s- P3 K8 K6 H  o
  e5 w8 F' n7 f. a
</script>

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