返回列表 发帖

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

<style type="text/css">
' C7 W* A- h0 j2 l; B- B2 }#supertext {
7 z( Z2 z: [) f  h3 Fposition:absolute;% J* a) I2 U/ c0 w
left:0;
; [8 Q  m' L3 n% ~top:0;& F4 l1 I  M) f* Z; l6 c
visibility:hide;0 z6 j! p, m: m" s5 r/ @8 g6 X" u
visibility:hidden;
$ z0 e9 F' I- a7 T' ]: u8 X}
- j+ |! q- [/ f2 p</style>' B; z8 q2 L8 n  J4 ]- e% T, h) h( x
<script language="JavaScript1.2">; G( u5 n8 h: G9 N1 i
<!-- 改变下的字体的大小。颜色-->
% r9 p. K1 o9 p( F! g  n: Dvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 d+ u- _+ G0 k( Lvar hidetimer='';
  W4 V% N7 }" N7 V1 k4 t, w<!-- 改变下的弹跳速度-->+ W# Y, B- x( w6 Y
var BallSpeed = 20;
9 i! L3 F% T1 x% ?8 R  R; E5 Avar contentWidth;3 N, f+ S' X- c/ ]
var contentHeight;
/ \- u) X" R; ~; o1 K6 A' qvar maxBallSpeed = 50;
  j7 u. L0 w9 u, u+ Z  S# \( k0 w0 V; ?0 K. y
2 _3 j; q5 M& H5 @- u) A, d9 f
var xMax;
' x. R' ~* N% T1 Zvar yMax;
& u2 B" b3 [( U! lvar xPos = 0;
* z1 \9 J6 _' [) y4 L9 C$ ^* l) `var yPos = 0;% _5 q# O1 q& C4 C  S
var xDir = 'right';+ o& E9 r" R0 L
var yDir = 'down';; \3 ]' k) m% m3 N/ h
var superballRunning = true;$ W# r" v) e3 \9 y( P2 K1 ~
var tempBallSpeed;  D6 n2 m! X) ^- }9 ]$ N0 ?
var currentBallSrc;
/ \/ N, ~" ?6 ]" h1 b3 W' ]var newXDir;9 M6 s. G; R4 l" |* ]
var newYDir;
6 k( H. _4 \& h6 d( ]  V8 H, e$ R( `- }  b: q, A& f: k
function initializeBall() {  T. N. k" J# u1 ~  `! C4 n  E& O
   if (document.all) {3 P6 h8 a& ]( M+ b
      xMax = document.body.clientWidth" O/ {1 v  A1 |4 P2 v
      yMax = document.body.clientHeight
1 d& ?: |. \% d2 P# L, R! D& {      document.all("supertext").style.visibility = "visible";
1 H( s/ I, J/ B0 D      contentWidth=supertext.offsetWidth3 P2 M, ~4 w% p) b5 [, E- o) T& _
      contentHeight=supertext.offsetHeight4 ~0 R: _* D: L( m
      }2 m! |+ Y5 C) K2 m$ F4 F5 V; F
   else if (document.layers) {
' c3 ?) |( O- V% J' s      xMax = window.innerWidth;
% o+ e" I8 B6 q* Q/ E% j      yMax = window.innerHeight;
4 f! u" Z8 Z/ X: V: R/ g' Y      contentWidth=document.supertext.document.width
& P4 g' ]" |; |( _      contentHeight=document.supertext.document.height0 j/ h3 O$ W; u$ E+ \; q
      document.layers["supertext"].visibility = "show";
" K# U1 u. m# W0 I# E: k6 D      }
8 m# g4 z- w6 r) H  ]5 ~* u   setTimeout('moveBall()',400);
: m" q: ~  Y5 g5 m% |   if (hidetimer!='')
4 T6 h" Y$ O/ e0 X7 K# s   setTimeout("hidetext()",hidetimer)
* O9 j2 l9 R4 I) i1 N& W7 X, V3 b   }/ B- X5 Q5 r$ J1 u# @
% }1 B) f0 S1 ?  A
function moveBall() {
  c. O0 e6 X' O: a: w( S7 y   if (superballRunning == true) {2 ~' Y% g. S& d5 D1 u8 [
      calculatePosition();
, u! q) W" I+ O0 R      if (document.all) {2 i( ^2 Y1 z$ w, K$ G
         document.all("supertext").style.left = xPos + document.body.scrollLeft;4 I( b( W: e- S8 B' t9 o
         document.all("supertext").style.top = yPos + document.body.scrollTop;$ p. Q; X+ `( {1 L1 s
         }
) _- Z# m7 I  y      else if (document.layers) {
- z/ I' j* R; |1 `; M; @! Z9 P         document.layers["supertext"].left = xPos + pageXOffset;" @8 G* G2 P' L% T' l; R
         document.layers["supertext"].top = yPos + pageYOffset;8 f+ _' o0 C1 d: N' f  U( f3 A( g
         }8 R, Y7 ^4 b& s
      animatetext=setTimeout('moveBall()',20);
5 V4 E1 O/ h% u# H      }6 \9 s# U7 H  S& @/ L& }5 ~5 X& S
   }" f' `/ N* n) v4 x9 l* C. t
! H. Q) W! C; }
function calculatePosition() {4 R7 z" q- i6 m" R
   if (xDir == "right") {  w4 s2 l8 h5 R
      if (xPos > (xMax - contentWidth - BallSpeed)) {
6 y/ v7 X3 I( g& z& J) F- M         xDir = "left";; W: F3 z2 X1 @$ D! [9 h4 a3 s5 V
         }/ K6 O! d( m! E+ v, \
      }
% F# _- E& I$ O/ ~   else if (xDir == "left") {
- i7 M$ y& n" j5 X" C+ D      if (xPos < (0 + BallSpeed)) {
1 t1 h" _1 s8 C& |3 S5 d3 L" |, `$ r         xDir = "right";
* h4 ^' e" ~3 T1 \. Y+ K         }
  l9 b. K' R2 e2 p9 A) w9 T      }
9 U" a2 x% V+ x   if (yDir == "down") {6 c( ^. {! X) h' x5 {, g$ b
      if (yPos > (yMax - contentHeight - BallSpeed)) {
+ W' C3 ^$ m9 z7 H4 A. ]         yDir = "up";8 {5 O9 z6 |9 Y9 b% F- Q
         }
3 ^0 j7 t7 D4 n- }, y      }4 f  m( s" p3 c8 b! t
   else if (yDir == "up") {
( j/ W8 j2 p: f* {2 H: O: {      if (yPos < (0 + BallSpeed)) {, y: b+ s+ q7 f! `: T# `- {8 W4 Z
         yDir = "down";! Q0 D& X  t, \' m7 ^4 Y
         }
% V  Y4 R* q* |& @5 Z! D      }. C$ w# o2 e, i. ?
   if (xDir == "right") {4 W6 ]$ l& \' s+ d7 y; j6 D
      xPos = xPos + BallSpeed;, D) {) A3 x: j" H# {9 j
      }
- ]$ l$ J* D/ _! h   else if (xDir == "left") {9 |$ N$ C- v7 ?' O8 o2 n& |
      xPos = xPos - BallSpeed;
$ V5 y3 [5 O6 S+ i      }
2 s; B& r' e& h% ~) ]! C   else {
- j! I$ Q6 ]  W0 ^- Y" z" D$ i      xPos = xPos;
' [- V) r  j# s      }% v5 s, ]- a  F3 j5 e7 t) C
   if (yDir == "down") {; x& [1 }2 D! @$ C: l8 R& I
      yPos = yPos + BallSpeed;
3 F" M( O/ j- C0 Q) o2 }. \      }. Y1 E' P% o7 C9 R1 l' E2 }
   else if (yDir == "up") {
  m5 }3 Q2 P+ j  ?$ w9 d2 W* _      yPos = yPos - BallSpeed;# [( L) x$ B4 t  D6 _
      }
3 P) ^) I0 i( Y+ x: J( H0 \   else {# h2 I* m! X2 C4 e' R$ N
      yPos = yPos;
! O* B' w( I( X      }
# j3 p( [* F7 I" S7 [$ p: y   }
2 g5 r' `2 o! f, b3 @3 j( D) I
function hidetext(){/ d0 f/ Y, K+ N! x, r2 g
if (document.all)* t4 i# L/ s% N: Q# u# F  a0 w
supertext.style.visibility="hidden"
) m- }! x  ^7 {2 C( \' f2 Qelse if (document.layers)) W" v) f9 o, |: l# Q4 D; }# y
document.supertext.visibility="hide"; h" L1 I) d% X% Z( P+ z
clearTimeout(animatetext)
$ M; A8 V2 k1 f% @. s! H}
7 ?) Z! _4 o: D9 I5 N
- l1 S" @( T  ^. z2 i1 Vif (document.all||document.layers){
2 `) c8 ]9 q3 q" R" v$ x# gdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 K0 K+ |8 q5 b  e- k: x5 q
window.onload = initializeBall;9 ^5 `$ x# S! v* y4 Q
window.onresize = new Function("window.location.reload()");
4 \& d9 e: N  k. [4 @( G}
9 w  ~% `3 O' q8 m$ o7 ?
6 j. n% ?" V; z" A& y</script>

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