返回列表 发帖

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

<style type="text/css">8 K" j' U' E0 w. l1 u
#supertext {, T2 G8 u8 @- R9 g* u9 h
position:absolute;
6 J* u. t2 v" q% P" K2 Xleft:0;1 o* ]! p( w+ F
top:0;
) q" i7 L+ `: N' Y! F& Evisibility:hide;
. g% \2 @9 a  F9 Rvisibility:hidden;
  z) {( g* R9 x1 A1 [# }}: C, B5 n; k/ \7 [6 c; T+ a
</style>
( w# S4 o1 T/ A<script language="JavaScript1.2">
' U) m+ C1 e; r, S) m<!-- 改变下的字体的大小。颜色-->( U5 F) ]7 d2 B8 e! L  D
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% C4 X6 Q& T# i/ @/ Mvar hidetimer='';) l/ K# N, f' f" z! z  X9 U
<!-- 改变下的弹跳速度-->
- a) @9 P1 |# C& H4 m$ j3 E3 zvar BallSpeed = 20;
$ L; E1 v# h$ B+ Jvar contentWidth;
; O" `: D* E! Gvar contentHeight;# o! p' h& e3 d# d9 K  F
var maxBallSpeed = 50;# x3 U# p/ v8 I% b; X! c" x2 L
- J$ g& q" n% O) F6 v7 a

' w7 _: l% d0 _" ~% xvar xMax;; m' N  @( x& ^7 i% x
var yMax;" d0 G9 H2 t3 M' ~* k! }& Z
var xPos = 0;
$ ^  F& h( R: `: s4 I8 n5 Wvar yPos = 0;
, K! S0 S9 t, {. h! Y$ a4 r& Rvar xDir = 'right';
* i8 s/ W9 m% |, l4 r& i  D7 z4 Mvar yDir = 'down';! f. t) K0 Z' g! l% _7 D: S# n
var superballRunning = true;) e" w! }1 S; `" U4 K: ~1 I0 }9 n
var tempBallSpeed;
# ?/ v  ?3 H& x; O/ @& o5 K1 `6 pvar currentBallSrc;8 i. f, q9 a$ U& p2 H$ k
var newXDir;
" }9 A# T( ?' u; E# j4 |. Uvar newYDir;9 F2 t% e. s8 R% y
8 m8 O# d' h: a
function initializeBall() {0 ~3 [, u# V' k
   if (document.all) {
; S# `3 T$ D8 t$ P$ O( S' f      xMax = document.body.clientWidth
: Z7 s$ o% g8 L! ]( ~* E2 a      yMax = document.body.clientHeight" J% c+ }, j3 o) t
      document.all("supertext").style.visibility = "visible";
( n7 k0 \% R/ L      contentWidth=supertext.offsetWidth9 s8 _& m$ L9 Y
      contentHeight=supertext.offsetHeight7 |5 D- [% w3 z
      }/ Z( }) T; J- x3 w
   else if (document.layers) {
8 q2 Y/ r# ]/ K! w8 W8 p2 D      xMax = window.innerWidth;
+ w3 _& e: X  [3 }( k      yMax = window.innerHeight;6 P0 w7 ^( v( M, z+ t7 e" n7 D
      contentWidth=document.supertext.document.width
9 h" K3 ^2 ]8 ^0 `5 h  p+ j' r7 ^      contentHeight=document.supertext.document.height& `4 X8 ^8 J* }! ]
      document.layers["supertext"].visibility = "show";
' z& x- g6 I- j" m' m      }
5 n  b& s3 J0 s: F   setTimeout('moveBall()',400);! D, U9 U  M# d+ L$ ^
   if (hidetimer!='')& V  e8 _. y' g: }# Y
   setTimeout("hidetext()",hidetimer)& n9 K8 ]! h* s% }, }
   }( K) [- f: p/ V. l2 u% F' |

5 Z3 q/ L( K/ Yfunction moveBall() {+ O( C' o* E( ?8 J# j8 N: V
   if (superballRunning == true) {9 b6 i* d# z# z- U; {& ?
      calculatePosition();* B0 i8 I/ d( l8 q# m6 p! E
      if (document.all) {
2 O3 Z8 [, e8 b0 P9 `         document.all("supertext").style.left = xPos + document.body.scrollLeft;; [5 `1 q- Q7 \" Y
         document.all("supertext").style.top = yPos + document.body.scrollTop;
$ e) |/ e- [6 N' U6 ?+ I, v; j         }# g: t: K  L! |# a( [, f5 R5 e
      else if (document.layers) {" h/ t9 l5 s$ W/ ?- w' n
         document.layers["supertext"].left = xPos + pageXOffset;
9 P2 N3 P- I! b5 B+ T; l8 A: q         document.layers["supertext"].top = yPos + pageYOffset;. L7 k5 {: d2 F) P" I8 G
         }
# W4 @, \, x7 X' _! k9 \0 C2 ~      animatetext=setTimeout('moveBall()',20);
: O5 F. ~: T1 w0 i      }
/ S. E% ^- X! g   }
7 {7 q9 W9 l7 r4 `$ L6 l- R6 z4 D. x! z5 J
function calculatePosition() {
: d1 ]4 x8 n4 V; E% t% u   if (xDir == "right") {
$ _9 \+ q# n. n$ h" S      if (xPos > (xMax - contentWidth - BallSpeed)) {. Y# ?) A, c! T. J6 G
         xDir = "left";
3 s$ ^1 X: S9 I1 q- Q; O         }
, G" Z& U  I4 s( H8 e1 c  ?' {      }3 Y* S5 o! f9 n# ^
   else if (xDir == "left") {
; I* y4 }  [4 m2 |- F      if (xPos < (0 + BallSpeed)) {# G. K( X2 m9 ]1 d3 ]
         xDir = "right";+ ?& ^! k8 _! \( p! q  U8 v
         }9 d+ K$ E6 d# O' u
      }) ?5 }3 ?: N4 O& F
   if (yDir == "down") {0 G5 g7 H/ u$ a1 [# d% B9 g! u
      if (yPos > (yMax - contentHeight - BallSpeed)) {
; @# Y) Q9 p" {4 D- j         yDir = "up";8 J; z2 ^" i! z, [8 ?
         }
" B/ |0 s2 |1 _6 S2 s' Y: v$ k5 l      }
1 m! ~' u7 z9 S- F0 m# Y; D   else if (yDir == "up") {
5 ^* p$ B' s8 T' K      if (yPos < (0 + BallSpeed)) {
# n5 v  q1 ^5 `. e( P         yDir = "down";
5 m& K- I8 I7 Y1 P8 w' Q6 ~         }1 Y, c. ~6 H- r- S+ x8 C8 o' r' f0 U
      }
0 t  U/ N+ y3 e; G   if (xDir == "right") {
( _5 P3 g& m0 t3 V' \( _      xPos = xPos + BallSpeed;" H0 O5 F/ D; l3 Q
      }3 H) _1 h0 s* e- b2 D' N0 o
   else if (xDir == "left") {# z8 t8 h' ^9 \
      xPos = xPos - BallSpeed;4 ~) d7 C0 f3 N6 l. ^: A. e
      }
( H, w/ r5 K, m; t# i. Q   else {
/ r: V  u) a7 O$ b! G      xPos = xPos;! i  m: m/ E/ T3 M6 |2 {- @9 F
      }
: V; Z; j) ?0 ^) y   if (yDir == "down") {- h. V# l+ u8 |
      yPos = yPos + BallSpeed;
' R! ]4 F  O$ x' V3 j0 t      }: }) i5 f! _! o4 {& C
   else if (yDir == "up") {
4 k  r& v% S( t/ H      yPos = yPos - BallSpeed;
6 k9 Q) v$ T3 P- d2 Y      }6 _( K2 y' N. d. t  C% @8 t
   else {$ H4 S7 c9 v& X* M' @
      yPos = yPos;
5 B- B. z1 x" I3 T1 c      }+ _# k' x) R; M1 D
   }
) S( I! V# L, p7 @/ \: t/ s  g1 ]$ \/ Y, F. c% |. ~
function hidetext(){
+ C8 A7 \7 P8 z9 H: V% Kif (document.all)
) v+ D" A0 ^$ Y0 K; B% I9 l8 ^supertext.style.visibility="hidden"
% p6 u) r. M3 L/ `4 l. _else if (document.layers)
( \* R9 k1 i1 \# Wdocument.supertext.visibility="hide"
( S" |* M' h5 I" _clearTimeout(animatetext)" `5 f  Z* d, P
}
7 Q4 t" k# s: F  l9 V! p$ q' M& w6 w8 V7 Z  Y1 I
if (document.all||document.layers){
! _' D* Q/ W, k: wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')% H; V. M0 o; \( _8 K0 u! |% `9 ^
window.onload = initializeBall;
) k7 X/ m1 d9 o- v, f; K3 p- ^window.onresize = new Function("window.location.reload()");
& ?- S0 e0 F# [/ e& W; V+ v}
! c" Z& \- A8 `$ Q) ^5 M4 O2 m7 J4 F
& ~& Z$ Q' b2 \- t; X3 i</script>

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