返回列表 发帖

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

<style type="text/css">
3 r* G+ K2 R8 s7 v  x#supertext {
9 B2 A6 `% |( t8 C* U, a( N" Bposition:absolute;- l# _. q) B# w, X( t
left:0;
, X9 K4 \6 W# B6 v8 F  j7 otop:0;9 h$ V, P0 y" {9 ^; c
visibility:hide;
& V. ~( O. p9 \7 A& ^visibility:hidden;
, p1 \4 \/ P7 x1 j. W% A+ y1 v8 P}8 U8 ~, B! |5 d9 Z
</style>
! Y: h) v5 U  a* p1 x<script language="JavaScript1.2">9 q" M% N, X) {5 ^  F8 N
<!-- 改变下的字体的大小。颜色-->5 j& A- n" k- f" `7 m  `9 e
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
* j. g* u. e# e# c' gvar hidetimer='';7 Y" D4 z% b3 Y9 v6 x7 R
<!-- 改变下的弹跳速度-->2 G- g* k2 o! h6 g/ Y; U6 d
var BallSpeed = 20;
% U! D, c) C  {. N& F0 v! [. tvar contentWidth;3 Q& C* O1 P$ |8 X4 o4 M. }( g
var contentHeight;
8 I8 k' e% n. }8 H/ xvar maxBallSpeed = 50;
$ R; \1 G' G% |, o" m2 b
7 T2 |& ]8 t. X
7 w3 c1 r0 w& J( J3 h4 p" k. S2 zvar xMax;7 r8 @8 h4 F" z, m
var yMax;1 V8 W% A  m7 D4 r- o
var xPos = 0;0 D) U) \' d( z
var yPos = 0;; l8 J4 E) Z1 N, \6 P" \% q
var xDir = 'right';* j. g$ h' c$ c5 i
var yDir = 'down';
0 u5 O! g) N' s  Ovar superballRunning = true;
9 s2 p7 l  n5 m9 o8 Hvar tempBallSpeed;2 ^& e! H& U' \8 Z( j
var currentBallSrc;, u; ^$ b: _1 p  D) q
var newXDir;1 u- V* M# T' [
var newYDir;8 e( M( P4 l/ t8 r& m

! e. i' i/ O' e0 kfunction initializeBall() {
6 X5 h  _2 h5 k  Z# B' F   if (document.all) {: b" ^5 Y- K; H! W) q4 A
      xMax = document.body.clientWidth/ Z& P6 m, J4 m: }. |+ `) J% }
      yMax = document.body.clientHeight
& F3 K# f# D2 W; e; A      document.all("supertext").style.visibility = "visible";: f) \: Q7 E8 Z0 _; o3 W8 c
      contentWidth=supertext.offsetWidth
6 I7 b! j7 e6 k8 i* n, d/ j7 s      contentHeight=supertext.offsetHeight" B& I8 ]. ?( s+ }  L; z$ S
      }8 C1 O7 C# Q! m4 m1 x8 U
   else if (document.layers) {
2 w' c2 L1 m+ Z  U! M      xMax = window.innerWidth;! F& h$ v- \" h! C, m4 b
      yMax = window.innerHeight;. ?2 S, U4 w1 w
      contentWidth=document.supertext.document.width: j" {) ?& `# A! q& q
      contentHeight=document.supertext.document.height
: N( l* H3 k+ M* D0 u$ E6 B5 ^+ A      document.layers["supertext"].visibility = "show";
) E5 I) p% }" c& M: |3 W; x4 G      }
  x2 f6 f7 c) p$ ?! N( U6 N3 `   setTimeout('moveBall()',400);
, P+ }# V3 A  P   if (hidetimer!='')
0 G+ h* m; P" q+ S% l   setTimeout("hidetext()",hidetimer)0 ]! G2 l# }1 x7 Y1 l3 g9 i
   }2 k8 N9 @: B/ J; y8 }* C9 [
; O' d6 U, ~* \; c3 n+ m
function moveBall() {5 d& _3 r& p% {# U" Y1 R6 _
   if (superballRunning == true) {: g5 r- B5 |2 b- i& ]" t( H1 H
      calculatePosition();
% r; g, R0 w# x      if (document.all) {
( a: f$ Y6 \6 f         document.all("supertext").style.left = xPos + document.body.scrollLeft;' Y0 ~; v1 X; W3 _( a  ?
         document.all("supertext").style.top = yPos + document.body.scrollTop;
* Y4 D: j1 f6 r# O+ u3 I: h, ^; D         }$ U( V' \+ r% {$ V9 F! F! p9 J
      else if (document.layers) {9 A# A* w# T/ H
         document.layers["supertext"].left = xPos + pageXOffset;8 D  r3 t1 `4 w3 G( n: m: }, F7 u
         document.layers["supertext"].top = yPos + pageYOffset;
$ `8 ~7 f0 T6 X7 C" B6 y0 L2 w' M         }8 o* t# _6 N9 _
      animatetext=setTimeout('moveBall()',20);1 v0 W* w9 ^) ]/ _3 z: o
      }
4 {: y. Y! }. L; T- n   }! v/ Q; F& L9 W" T9 \; u

5 k/ B* s: P: ?  P7 X7 Efunction calculatePosition() {
; {# d! K3 \& _1 t   if (xDir == "right") {
+ w% [1 \- k8 c' x: v# b. ?, C  B" K      if (xPos > (xMax - contentWidth - BallSpeed)) {! F  C1 L" n2 M9 t2 j, x( q) ]
         xDir = "left";+ M8 r$ N) ]6 |! l9 e& l% X* \
         }
8 Z. h( C7 Y+ q! P5 F      }
+ d. }; Q7 `/ q8 v8 e   else if (xDir == "left") {
  d, H0 }1 g+ ~- E3 w" }      if (xPos < (0 + BallSpeed)) {) ]+ N, f2 V2 |, r7 a4 X' c( o
         xDir = "right";
9 |' I( Q! W, o/ X         }/ e: o. g1 U! I5 Z
      }$ p# j2 l2 _* Z+ f6 \. U, q
   if (yDir == "down") {
2 A4 [4 I5 q; U8 a      if (yPos > (yMax - contentHeight - BallSpeed)) {* t( \- g3 R/ b3 ]' K
         yDir = "up";
" X' d7 @; c5 q# f8 y. o0 V         }2 R+ e# Y& @- p/ @- T2 W  b& B
      }
! \' k7 A* m: e0 I4 f! Y   else if (yDir == "up") {
" I9 i1 C7 N- M' n( N" D      if (yPos < (0 + BallSpeed)) {) E% V2 K7 A4 o2 \. X8 l* Z
         yDir = "down";  d( F- ?* P7 w  D- \
         }& |: R# L! {6 a7 f/ M6 F
      }& H  E1 _2 u; q( k  M! y! S( P$ L
   if (xDir == "right") {: F) S0 k9 t# s" _( r0 }6 }6 D
      xPos = xPos + BallSpeed;3 D. C! c5 E2 L  W6 N6 i
      }
; }3 U% V+ o# [$ ~. ?8 _' f* c   else if (xDir == "left") {& _" d) {+ ?2 u5 I% s' R
      xPos = xPos - BallSpeed;1 {) q. H* i+ f
      }
! l; ]. K. m) Z   else {
+ n# G) o; O: h      xPos = xPos;" n5 T* K* H+ W& [; n
      }0 }' H6 R; q0 E( ]& t! w% e
   if (yDir == "down") {& n; \% `: C, l2 m2 v/ I$ D# S4 _- b
      yPos = yPos + BallSpeed;7 b3 T1 q, O" c4 t% M
      }) P, C7 X: @. F* |" r5 i+ `
   else if (yDir == "up") {; @5 e+ I. \$ q9 j! O! [7 C) X
      yPos = yPos - BallSpeed;
1 G8 ^2 E+ z; p4 `$ x5 s9 s      }7 t6 J1 z) F$ ?# w
   else {- F8 I* }: m) Y3 G
      yPos = yPos;: ?3 g" Q0 J  o6 [. y( V) k
      }) Q* ?  X& F* {  r3 _
   }( V+ P. o# i8 P5 j
, a# F$ F1 m6 I" X% P7 `6 d
function hidetext(){
6 V2 U/ D% o" R9 d" `7 B0 jif (document.all)  u7 q% }( n0 U# |2 Z0 [
supertext.style.visibility="hidden"
; Q) g" V% v) ~/ m# B! Aelse if (document.layers)- N* b3 E0 `/ q1 a# z" k) |
document.supertext.visibility="hide"
, Z7 g6 f: v/ E- d2 KclearTimeout(animatetext)
2 }' m1 }  o4 ~}5 W; I% r% {% m; Y* C

' |; W1 b) j6 D* `; z( e9 R$ Iif (document.all||document.layers){
: N! p: s  Y. ]$ O$ y; L) ldocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), d# y8 L9 G* @8 {! Q" G
window.onload = initializeBall;
( b. C, R- m, uwindow.onresize = new Function("window.location.reload()");
, ]- ?$ P3 K( a' o  i# }}
( D9 G" `* Z9 u
" M0 K  ~) v/ `& y# k) z, m</script>

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