返回列表 发帖

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

<style type="text/css">
/ k, J: O( |7 n- b- a#supertext {
0 x6 H2 a! t1 Hposition:absolute;
9 _& X2 k4 Q2 vleft:0;
9 W& a; w: z* C3 atop:0;; }: i% m' c9 @/ _1 A) |0 f
visibility:hide;8 a9 q3 K2 E9 {- i
visibility:hidden;
1 b6 T4 b! f5 a}
  @, Q) L! Y; w' V4 W4 D</style>9 N3 c- B9 V7 ]: o
<script language="JavaScript1.2">8 \5 V3 _- F' \% r
<!-- 改变下的字体的大小。颜色-->1 f: o/ ~+ R# s, j+ V" m1 I) W
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'( _$ {. G5 C. G8 u- ~  w
var hidetimer='';. e" d0 b7 ?- o
<!-- 改变下的弹跳速度-->$ G7 b6 i) e  n2 j
var BallSpeed = 20;
+ e# E: ?8 |0 v1 Avar contentWidth;0 m$ l, X8 s" g8 D, k4 m  v) T
var contentHeight;& t6 Q/ a) b% }4 I5 m
var maxBallSpeed = 50;
, L1 ?) F. g0 u4 @0 R+ i' \8 f3 k* C
5 S$ Y9 P- C2 e$ G/ }% s! ^( P- t' I' M8 y- i- W' A" E- {2 X
var xMax;
* ?! d* R' \$ E* J- svar yMax;
- C, {1 H& b# ]' B5 {# vvar xPos = 0;$ W/ P* Z, O% P4 ~/ w, G
var yPos = 0;
: {% J* L& z, x0 F6 i- {7 q, L' ~0 Bvar xDir = 'right';
( H4 n- D; w0 {- p) M  E! e+ ?# kvar yDir = 'down';
8 k) i+ q- Q, M3 R, Xvar superballRunning = true;
( I+ G# Y7 H+ _& [1 w- p3 \- a/ jvar tempBallSpeed;
" E# x- P$ Q, S9 q5 Ivar currentBallSrc;
7 _5 z- d, s( Evar newXDir;  i1 L  U( O: [. P" i3 f7 a
var newYDir;2 Y1 Y4 Z% S' ^* B7 e" v4 U. a! C
$ x7 W. D( X4 f' E# ]
function initializeBall() {
' S# |6 d0 l& r1 G9 a   if (document.all) {+ e) e* Q' w7 i) k: e- _5 Y  F+ U
      xMax = document.body.clientWidth' ?3 j( H3 `$ y6 Q
      yMax = document.body.clientHeight
/ D2 m# q0 _1 S      document.all("supertext").style.visibility = "visible";
, c4 K; L9 F2 p5 Q6 M3 x- r      contentWidth=supertext.offsetWidth& [! J/ E3 h% |9 X- s2 l
      contentHeight=supertext.offsetHeight
! q; \( N, i, N3 x3 o) \. a      }
9 K0 o. d& |8 l   else if (document.layers) {; k+ X. S1 L% U4 s6 }, T
      xMax = window.innerWidth;) E) {8 V" ^0 u
      yMax = window.innerHeight;: K& q6 Z, [2 j6 O) t& Y' a
      contentWidth=document.supertext.document.width& B$ t0 {5 y' V' F! ]1 j. |
      contentHeight=document.supertext.document.height
4 k% d, V7 w+ T8 p( A. U      document.layers["supertext"].visibility = "show";
0 u7 e3 q7 |2 ~4 A      }1 R7 m, ~" \$ W, S# v! |+ j& g
   setTimeout('moveBall()',400);
+ w$ L: v  Q; ~3 q9 q" j! A   if (hidetimer!='')% g; a' ?( O& I# [. E& b: e
   setTimeout("hidetext()",hidetimer)! ]* Z8 v) I! s& M2 W! y
   }: ^0 T( U0 d' r+ G, z1 H7 w
. \+ r6 S% D- b  S4 S
function moveBall() {
  r" a) L9 s" n& T7 D" ^   if (superballRunning == true) {: S, i% {# V6 `, n: Z  r
      calculatePosition();$ W4 b: m/ j+ f! b
      if (document.all) {
: l& k* a( q/ r2 y         document.all("supertext").style.left = xPos + document.body.scrollLeft;
5 V$ S" o/ |; O7 _         document.all("supertext").style.top = yPos + document.body.scrollTop;
5 H+ _' O, j; s# V+ R% u         }
# J% }4 A7 p: b      else if (document.layers) {2 l5 i  ~: A2 y  _. c4 V5 X
         document.layers["supertext"].left = xPos + pageXOffset;4 j/ |, n0 C9 q7 N
         document.layers["supertext"].top = yPos + pageYOffset;
: s0 p6 a( q8 Q7 S. G3 k         }
3 }' L; w2 Y8 }- ]3 E      animatetext=setTimeout('moveBall()',20);
3 v3 W" q3 Q) I1 V) w. C# |      }, v& T1 W( A( w- n/ g4 q$ `* {, B
   }! ]; z' N, W; e

7 b! z% Q1 X4 h+ D+ k+ u2 Z/ ^function calculatePosition() {, d. t' n1 u; @1 P, u3 A) @
   if (xDir == "right") {1 O8 G0 s  _. ~5 o2 X
      if (xPos > (xMax - contentWidth - BallSpeed)) {
: S. @& M  H, b* C& d7 ?         xDir = "left";+ A7 g  \6 P: [7 J$ h, G  T. B
         }
' p$ X' A- U  X, e8 p+ a. O      }
7 N- N. ~/ b" l   else if (xDir == "left") {
, P' X* U) D  A% w% K# d      if (xPos < (0 + BallSpeed)) {
! t, G* |: A2 @; v, W+ K1 C         xDir = "right";1 @: ~/ }4 C1 e  V
         }
- ~! F* n1 g: a2 `# q5 {      }3 A! E' ?, K$ T7 `. k8 r! b7 n
   if (yDir == "down") {- b/ m" Z3 G* l8 T) k& O& I
      if (yPos > (yMax - contentHeight - BallSpeed)) {) E- R' ~2 `$ J$ B$ d
         yDir = "up";
5 e4 O9 L  @: {6 H$ U         }
: |$ R+ y* T4 X! e( x1 s4 ?      }
: @' t) n5 E7 O1 u+ X   else if (yDir == "up") {+ C. }. d4 y8 j8 l$ k* d1 j
      if (yPos < (0 + BallSpeed)) {
8 T, [6 D6 y' |# k* j; d         yDir = "down";
  t4 \7 u3 K  T1 X, p         }! T( u0 X$ z3 h! W# O3 I3 q+ S( P
      }
' g! @8 H6 b) U( B5 I* {' Z; t   if (xDir == "right") {: V7 P, G) b/ ^2 o6 N! C' X! }
      xPos = xPos + BallSpeed;
* W+ `3 ~3 R$ e, m3 P5 M( c( @: D2 p      }
+ f0 E8 P, @: x8 S* x6 y9 t   else if (xDir == "left") {
: H: }3 u5 ]5 H) x8 j( S      xPos = xPos - BallSpeed;
+ H7 c: F3 @: {* e8 x      }
# J* m2 `& E1 ?: C! L+ E, }; U   else {2 ~$ s# J) ^3 F+ p# S0 Q
      xPos = xPos;
2 A0 Y$ t! b" q# I2 ^4 q6 b      }
' u& A( H5 N9 n8 }1 P   if (yDir == "down") {
9 F, `  j2 J6 ^5 S1 |      yPos = yPos + BallSpeed;
% h1 P& l# Z; M1 G- ^) s      }
4 o/ M- ]: h/ N' `- ?0 _# v/ v3 p   else if (yDir == "up") {' [/ e8 J; ]8 u" f
      yPos = yPos - BallSpeed;
# ^) w8 q  ~2 w  a/ F: ~: Q- X      }
. T7 Y! I" v: A( ?, m$ z   else {5 P3 m4 C7 ?# U. X% q, x
      yPos = yPos;, `3 J$ Q4 ]4 l4 c
      }
2 q; [8 j1 D2 e- B4 z/ t   }$ D+ ?. c( a* r# J5 n: Y1 L

, @/ `& D2 F1 T- p- t4 q# Ufunction hidetext(){# p2 p# `2 V8 Y& h
if (document.all)- U" ~# e7 Y9 o- f& V$ r
supertext.style.visibility="hidden"
0 {" P0 u0 c) B$ kelse if (document.layers)! e3 d( x) e8 K, w. h+ i2 J
document.supertext.visibility="hide"
1 d) x5 z. z0 _3 j, k0 X, Z* V1 gclearTimeout(animatetext)* @- J7 F* q2 U/ t; q
}' t) z2 `" f- y: [& W, f
; O; \9 E! X5 N9 b
if (document.all||document.layers){
9 {2 W3 r- d' j5 a: D' Ldocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
1 Q- i9 B. T; Vwindow.onload = initializeBall;
! l4 a5 L$ K5 m( d. m- [window.onresize = new Function("window.location.reload()");) o# f2 X2 U4 D3 x
}4 p3 [  h. W5 O# c0 z

( M" i  R. t1 l</script>

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