返回列表 发帖

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

<style type="text/css">
6 J# m0 U) _9 i6 i3 ~#supertext {
7 `2 h# u( t+ z- j1 B/ r9 Qposition:absolute;
9 s) [+ h2 B, a0 q2 ?" T7 E9 F0 J0 N# yleft:0;
& T& L! P* h- F8 ktop:0;  n" B- l% p8 H, T6 L4 O$ w
visibility:hide;
1 C3 R7 |4 K: a2 @1 P+ |! m! qvisibility:hidden;
! K$ r  M& z' `! k7 |0 p}
" B# [5 i; `# v/ \; |# b/ B</style>3 A  T7 |7 v2 H: }* M
<script language="JavaScript1.2">* _8 a# x+ J# D! W* C7 l
<!-- 改变下的字体的大小。颜色--># f; W# t/ y9 y3 y4 H. M8 F1 M
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'; s$ `! X: g" H: E5 J; F7 h
var hidetimer='';$ [$ f  w5 ~0 h7 g1 X) c) @8 ^
<!-- 改变下的弹跳速度-->  f. c9 `/ [5 G4 h) l$ h
var BallSpeed = 20;8 V8 L2 L+ N8 I
var contentWidth;
' ?* u% m; i$ f" a; kvar contentHeight;  c( Z  i8 u& B8 H
var maxBallSpeed = 50;
+ z) _$ o* N% I0 H8 j8 T( I0 \6 {; G/ [& f

$ Z! L: g. D. L& q, i: `9 q+ _! Vvar xMax;
5 u$ a% M* F$ avar yMax;. [1 O& F* T, D4 u  p8 Z$ e
var xPos = 0;) b$ f) p* ~: _' F$ x$ Q
var yPos = 0;8 m1 V- `2 x, F
var xDir = 'right';
) z. A3 Q8 u2 c& s6 K+ yvar yDir = 'down';4 ~/ ^% i0 v1 K% O
var superballRunning = true;
5 A& a2 a6 g  P1 ?9 d' i2 rvar tempBallSpeed;* W8 R6 T, R5 I3 \5 G1 D( l% l
var currentBallSrc;
" }7 W4 ?9 z: N( U  g' ^2 ^var newXDir;! W2 s* B- c2 ?) ^
var newYDir;" J' v  C& s+ W/ |# G) a7 a

( q2 ?' \! B6 W$ jfunction initializeBall() {- _7 z' Q3 B' Y) Y
   if (document.all) {2 r$ M# X+ Q$ _" ^- M3 N
      xMax = document.body.clientWidth
7 D2 V8 D+ {/ R* z' \! D      yMax = document.body.clientHeight1 V2 t3 }6 M0 e0 k) `/ ~
      document.all("supertext").style.visibility = "visible";# X& z$ p/ b! i: }4 v
      contentWidth=supertext.offsetWidth2 r  z, I6 E6 C9 \( A" P0 {, ~
      contentHeight=supertext.offsetHeight; p. L5 a' _( d0 O+ `
      }$ A- A1 E% T3 P7 M# W# D
   else if (document.layers) {5 X/ e$ p% ?) @* ]' z8 F; V
      xMax = window.innerWidth;
: L+ A  @5 {! o      yMax = window.innerHeight;% V+ h. Y+ ~( @0 H; Y6 u
      contentWidth=document.supertext.document.width# a% p  k; a" }8 N4 Y
      contentHeight=document.supertext.document.height- x) M) d: l, L9 F4 A
      document.layers["supertext"].visibility = "show";
2 C5 Y, w2 U/ ^$ t      }
% N* {" h. Q7 t, n! Q1 V; h* o2 ?   setTimeout('moveBall()',400);
; S7 u( a/ R" J8 ]4 G8 t   if (hidetimer!=''), {6 s) S8 l0 w/ U) Q- o
   setTimeout("hidetext()",hidetimer)4 @9 T$ r4 s/ o2 o& A8 w$ |7 H
   }
& D, x% x0 E( {& h0 y' N5 x0 g$ [! C  J
function moveBall() {! l' G- z0 s! K( D5 B" y
   if (superballRunning == true) {
2 T5 a2 L# b4 K8 b      calculatePosition();3 k) b' W' ^0 s" l
      if (document.all) {
3 C4 h2 x, n, ]- w: Z/ V         document.all("supertext").style.left = xPos + document.body.scrollLeft;
% ~; U( h/ E! z: H  Y         document.all("supertext").style.top = yPos + document.body.scrollTop;
5 Y+ v! {0 q: G- l         }
8 z; w+ k% v' D. L  I/ k7 b      else if (document.layers) {
. x. L+ X, ^1 Z- H         document.layers["supertext"].left = xPos + pageXOffset;
" e( N% v  E  b         document.layers["supertext"].top = yPos + pageYOffset;
: P3 R, }3 ^" v+ G# Y         }
, f. \& F' M2 f      animatetext=setTimeout('moveBall()',20);
: i  N% w) h) D4 ?9 _. P0 p- z      }3 e9 Z& X# u) ]% p1 i6 q
   }
" @4 d1 W( F1 ~3 n" E! Z1 I( w/ l+ c0 _2 \4 d. Y) ^6 D) `
function calculatePosition() {
. U5 l4 B, [* Y   if (xDir == "right") {
, z, V4 V) {4 b      if (xPos > (xMax - contentWidth - BallSpeed)) {, j6 Q. g9 s: o" S) k: Y4 B0 \7 G+ e
         xDir = "left";
, q5 n- y4 W3 E9 h# R         }
, B: T* S3 [* j      }
, Z/ v6 Z9 A. A8 r& D3 t, j7 R: i   else if (xDir == "left") {
8 `5 X" z" j5 D4 @5 s& s5 z      if (xPos < (0 + BallSpeed)) {! S  p+ {6 n! g7 c
         xDir = "right";, z/ `) _& d0 }& b4 R7 _
         }, c$ {+ f1 r) Q6 ~
      }
" _' a. x' Y& E: ~/ l" F   if (yDir == "down") {5 p) ]( G+ F  @  h. Z# w, K
      if (yPos > (yMax - contentHeight - BallSpeed)) {; h! Q, ?" I1 g4 |+ i% D( n
         yDir = "up";  q- T  Z$ u5 d/ @
         }  t1 I4 E$ T! M3 G. M  f
      }( @' w- _/ P, g! O* [7 j6 l
   else if (yDir == "up") {
& p$ k3 g1 ?8 f# N      if (yPos < (0 + BallSpeed)) {, V$ M1 P9 o$ [6 ~
         yDir = "down";: a6 n  l6 S/ U! X
         }2 b$ ]% C1 L' d" z5 C
      }
9 ]' U7 I6 E  x4 Q$ G0 ?   if (xDir == "right") {
% S' R; o& {, Z# U- \" H0 ^) {$ s      xPos = xPos + BallSpeed;
9 r$ F: h* i6 N3 P* A      }% K, C9 D6 a/ a# S4 q7 U( Q# E
   else if (xDir == "left") {
$ y2 U$ Y9 ^9 G' D) u% O7 A      xPos = xPos - BallSpeed;+ U/ G6 n4 b8 `' |4 v9 w
      }( a& p' Z+ w' W! j* S  l8 J$ Q
   else {
) c$ H4 F, Z. q7 Y6 J; ~; V$ @      xPos = xPos;9 m. ]8 ?* t+ r! c' N2 E
      }
0 }/ r9 F7 ^2 }  ^6 T. E   if (yDir == "down") {
/ Z9 t5 v- X4 h2 R  b      yPos = yPos + BallSpeed;
7 o9 `  m/ f  n* [( \3 X" w      }
: \/ X& s7 l1 B' j% i) ~   else if (yDir == "up") {
* P! k6 ]- v, x$ X  |# M: o8 G9 J      yPos = yPos - BallSpeed;
- l# n# b$ s8 R/ b      }
7 `& f& l0 x/ U; I) \   else {
7 }3 l! p0 `& {3 g8 ]% s      yPos = yPos;
% [( E' j  l' A! h( X. G" |3 N      }
5 V, @* d& h, c* G5 ?: Y- i8 }1 ^" _   }" y& L5 x+ K* x0 j

  y* Z7 l- {! c' \function hidetext(){
+ U$ ?3 W0 Y8 s, y0 N2 {4 pif (document.all)3 Q$ c0 b9 G1 D/ k! [
supertext.style.visibility="hidden"# |3 C  G! f. V7 Y; t& \. i' ]
else if (document.layers)% K: o$ |' v) s/ \! ?9 x
document.supertext.visibility="hide"
* T$ Q, C0 P. U1 r& jclearTimeout(animatetext)# R/ a3 P; a5 ?2 z1 T# s+ D/ G. V) v
}
: ^7 o0 v& ^4 X4 [2 L( w# b
. Q. `( a/ E: W9 i7 f3 ]& N  pif (document.all||document.layers){& F; u5 ~+ S  g) }- @; n/ e
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')' c2 Y& C8 D, |& V
window.onload = initializeBall;
" C& S, j" _3 i$ f: mwindow.onresize = new Function("window.location.reload()");, K% L+ u, U$ e' u+ p
}
; E. j& [3 @9 z7 L
2 q+ _+ E$ O* e# `( b) a% ]/ L</script>

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