返回列表 发帖

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

<style type="text/css"># s) t9 ~- t4 l  [# o& S
#supertext {0 f8 y& j! F' s/ e
position:absolute;( @, B5 n# F) n9 m2 i6 q! ~0 }
left:0;/ z6 {  h  N8 J# f7 N
top:0;
" _/ `- E: k! r1 Pvisibility:hide;6 s9 s( ]6 x; S+ n4 g
visibility:hidden;
) f; I, a( j" Z* ^}( p' `% g7 v' \4 Q* M9 |
</style>3 Y0 a, z$ w* o
<script language="JavaScript1.2">- y2 \& {. a( U$ y- r/ S
<!-- 改变下的字体的大小。颜色-->- o$ L1 I( Q6 P4 U
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'1 p8 I' @. p6 R6 \
var hidetimer='';
3 v  k1 @! @" d2 u  R$ w! R" b<!-- 改变下的弹跳速度-->4 C, P: z3 X; i3 c! e1 B% M: W# X
var BallSpeed = 20;+ [0 Q6 O2 w1 @( l
var contentWidth;
( g* O% Y- [2 B7 ^: X3 p) Pvar contentHeight;9 n' _0 g: z4 Q' w3 m% m. i; Y# {
var maxBallSpeed = 50;# P9 Q3 b" ~+ A) r7 x

$ ^: W6 S% P# ]! a6 a! F5 c4 K1 Q" o1 v4 D5 @
var xMax;
6 k2 p5 `! B" X1 B% {2 @7 I2 P6 Ivar yMax;
. I- n& y2 X. c7 f- q, c1 Ovar xPos = 0;
) W  o, R7 s1 C" a& C$ _var yPos = 0;1 l0 D/ k% F# \4 p
var xDir = 'right';
$ v3 R' z. s6 B* Z7 E+ u0 i( gvar yDir = 'down';/ A) T" v5 m! s$ {  m
var superballRunning = true;5 p9 I" t* Z0 Y1 \. e2 L) _' }2 R
var tempBallSpeed;
& {7 J5 U  R4 s; k9 _var currentBallSrc;: B+ M, \% `6 n' _: _
var newXDir;* `% y! A# D2 r3 t
var newYDir;) |( B+ M$ \0 v" Z- {

  Z2 H6 @# T7 B! ^5 V% J* [function initializeBall() {
6 s8 ~# U7 L; G6 y   if (document.all) {
# e1 @8 |) J) d+ N/ h; U3 X- }      xMax = document.body.clientWidth
1 G, L( O; G3 A3 p% B5 h      yMax = document.body.clientHeight" y+ A( _( f+ D; A) ~
      document.all("supertext").style.visibility = "visible";
; w+ F6 h. T# a& B9 @      contentWidth=supertext.offsetWidth
( j9 c1 D5 ^, g3 h7 r. p8 R      contentHeight=supertext.offsetHeight
( h9 Q" w# h" m) H& M      }7 H. f, C% U9 Q1 |. b
   else if (document.layers) {2 K$ ?) n' N) O* `  c
      xMax = window.innerWidth;
* U% a- J# O5 o8 {: b9 n      yMax = window.innerHeight;" [( ^% X$ u  @8 Y
      contentWidth=document.supertext.document.width: r& n( z# L. b/ _, g9 }
      contentHeight=document.supertext.document.height
, D0 j" s6 h! n2 [0 p      document.layers["supertext"].visibility = "show";. A9 h- g* _  k2 E
      }
' J9 @: i1 Q8 }/ }   setTimeout('moveBall()',400);
5 @- Y) ~0 \0 a: w   if (hidetimer!='')+ o4 q# D4 {' M3 Q: L3 t4 [5 q
   setTimeout("hidetext()",hidetimer)- \3 Q, i' {4 B+ P1 r( k6 u9 R
   }$ [2 ?8 v# I" X# s6 o3 r$ d

& y" h, Y; i: d1 ?function moveBall() {6 c+ ?& W' {2 }0 ^1 @
   if (superballRunning == true) {4 T- p9 y- s* B2 B2 Y5 d6 ^
      calculatePosition();
( q* i+ r+ B: O" l* \% m      if (document.all) {  @& B( s. W- Q
         document.all("supertext").style.left = xPos + document.body.scrollLeft;  Y2 p5 W+ w4 o. ~7 r9 G9 w9 Z
         document.all("supertext").style.top = yPos + document.body.scrollTop;
: g! x5 ]/ i2 @         }
. L" p2 c, y6 B( x! b0 o      else if (document.layers) {# [, T* P6 ~0 B4 B' A; g  g5 P- O& }
         document.layers["supertext"].left = xPos + pageXOffset;& R: Y) _7 H; |
         document.layers["supertext"].top = yPos + pageYOffset;
: i! A* V( r& k% y, l" _% a         }
3 q5 L+ k$ p4 [- t; b/ O      animatetext=setTimeout('moveBall()',20);
7 ?" \7 D! ^* W; n& w( {      }
( t; ?: W8 }0 y( H9 |   }; e) d3 A( P' q1 B% Q

. S$ [/ A& y9 q, g$ S: D( k2 Dfunction calculatePosition() {5 @% z) `$ L$ o$ _/ X) M
   if (xDir == "right") {( |& m5 r  w0 K3 X9 Q
      if (xPos > (xMax - contentWidth - BallSpeed)) {7 ~- f* a. s2 S
         xDir = "left";; O, x* c# T' q1 _
         }2 C2 F1 \8 D6 f: K+ X* z
      }& |, ?% M2 n8 x$ y# j$ w4 b. a' e% T
   else if (xDir == "left") {4 E* M# G0 n8 D: |& y4 {$ E
      if (xPos < (0 + BallSpeed)) {
- u  D! o# `. d         xDir = "right";
7 u) |0 C8 _8 L4 z' a) M4 D         }
: E. ?4 A3 y& n2 ^6 T$ k6 X. x. b      }. N; M; ~  V) |7 [# e* @
   if (yDir == "down") {' ]9 \1 N6 V  {: i' d
      if (yPos > (yMax - contentHeight - BallSpeed)) {
: m0 S8 S3 A9 h         yDir = "up";
8 i: p0 b+ U/ |         }* ~5 O* X  S, x9 [6 @
      }
3 \$ [+ A. u( _: M   else if (yDir == "up") {! [  E$ o! p8 T5 {( Z' p
      if (yPos < (0 + BallSpeed)) {* ~8 i8 @0 m1 j5 X/ ?8 m
         yDir = "down";
# A9 H9 t) E" k" \6 [* N, a( Z, l         }
" I6 M, M. O! Y      }2 g2 Q8 W) G, {+ E! h
   if (xDir == "right") {5 `  M$ v( Z. T% }) d
      xPos = xPos + BallSpeed;1 K: K: [  ~+ c9 a7 d
      }% @' ?+ [2 s  v' f
   else if (xDir == "left") {
, ?/ n* g3 @/ F& M8 C# S1 H' c      xPos = xPos - BallSpeed;5 C8 y3 Q5 t8 [! |- F+ c
      }( B% @" F) G2 P: w/ k/ E5 B
   else {1 g' G" x' [2 \$ P0 n4 r  x$ d
      xPos = xPos;; W- x. a; @0 U9 m! C( Y
      }
2 p6 b5 F; i- o   if (yDir == "down") {% R: K" f9 X9 ?5 s
      yPos = yPos + BallSpeed;; T3 {4 k2 d6 Z% e0 M$ F
      }) _! |+ t. \: U) D0 L0 ~7 e& B/ Q# H
   else if (yDir == "up") {
9 I' O! y4 I9 E) b; }2 W      yPos = yPos - BallSpeed;; S6 n. A1 [0 F- r  g
      }
+ H/ O3 q; Z8 o2 a& w   else {
$ T5 G$ l) P2 [# G9 i- P* {7 d  F      yPos = yPos;
8 R1 O3 @8 `" M0 g( J      }! F- n7 {/ T% P& `2 _0 ?3 r
   }1 i4 D. k- g$ U. T
# b: ]( U3 p% m4 j/ ~) p
function hidetext(){
' l# t6 ^& n% @/ Y) rif (document.all)
$ E* F5 P/ j) F( q8 d3 V8 ^supertext.style.visibility="hidden"
- l: v! O: r- N) g- g  J5 Celse if (document.layers)
# k5 f% R$ f1 y% m- E# t6 |  Tdocument.supertext.visibility="hide"$ e1 i0 @, Z) Y- D  o9 a% z, a, ~
clearTimeout(animatetext), Y* q% g: t$ _& I: g! C* x5 _( j
}
6 m8 o% r6 J0 P
9 d/ Y9 f0 ^" p. Hif (document.all||document.layers){
" C. d! U* `/ F: p, Q, Ldocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')# X$ P% S4 N1 }! Q- n* d
window.onload = initializeBall;9 \/ u) H( B5 w  C4 ]* D
window.onresize = new Function("window.location.reload()");  `! c8 e6 E  U& Z; ]! @' @8 `
}
+ t) g  l9 f1 n9 s6 W( Y7 E4 p, }; C6 @! k
</script>

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