返回列表 发帖

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

<style type="text/css">- x8 J1 h$ I  X- q% e
#supertext {
: E% C/ t4 u. ^- a$ bposition:absolute;
* g% U' K# `8 k" Y6 Oleft:0;7 T7 |3 U3 _- G/ [+ g7 s
top:0;0 o2 C& V" F+ Y$ U6 ~
visibility:hide;
5 B4 C6 }5 S5 C- uvisibility:hidden;  e# M9 a6 a5 @$ }- b; h$ c6 H: r$ V
}
1 ^6 ^+ \# k7 I$ p/ J/ f</style>' O$ o; |- Y- @* d
<script language="JavaScript1.2">6 B# Z+ E& q$ r6 u
<!-- 改变下的字体的大小。颜色-->
' l& P6 i6 _. i5 S/ g) tvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>') ~* C. o6 l. B, Y' ?" M& B2 x
var hidetimer='';
- w9 U1 O2 f  |" P% ]<!-- 改变下的弹跳速度-->$ z# G9 v' s  z5 L
var BallSpeed = 20;
1 o+ F. C$ G  N( b  z) a" Z$ Fvar contentWidth;
* H9 z! ?: s/ H$ h" uvar contentHeight;
* I$ G* |( k3 _; d) Mvar maxBallSpeed = 50;, e( G3 K* h7 n+ T  Q

' G* Q2 J' a7 p; X0 |, j$ k6 j3 d3 p0 c0 ~) r( S) y' q
var xMax;
+ [" Y+ [2 m' S% P" Avar yMax;! ?1 r5 Q; ?: @1 j5 n
var xPos = 0;5 m# }1 K* o: y/ X9 U
var yPos = 0;6 A7 h+ O# F. n# ^3 ^
var xDir = 'right';
* `3 {  b0 u7 {1 ]: {* [var yDir = 'down';
* V) Q% U( m1 F% U) m0 c- Ivar superballRunning = true;
. \1 [% z' M9 e( x  U' jvar tempBallSpeed;* _8 ^5 J3 Y3 i3 S
var currentBallSrc;
2 q5 `$ d/ Z( Q! d- W2 wvar newXDir;
5 z5 u% g' @+ N/ Qvar newYDir;
/ a  {5 @6 `5 v
" ~+ d( j3 }% wfunction initializeBall() {
6 @% G% E* f# [* r9 i- U6 ~   if (document.all) {5 X. ~# l0 @1 x( l  [
      xMax = document.body.clientWidth
! O3 [# Z6 J! [- U1 r8 @& y0 _- y- B9 n      yMax = document.body.clientHeight5 m7 h. q/ K9 P" W7 T
      document.all("supertext").style.visibility = "visible";
' N4 n! t/ Z# s/ `7 G5 z: o      contentWidth=supertext.offsetWidth0 T2 ?! T) m+ k: J
      contentHeight=supertext.offsetHeight5 T& z2 i+ J/ q: ^1 I' d+ m
      }
9 L5 ~1 i9 |. m5 w7 D3 @; c1 M8 {   else if (document.layers) {
7 A) d& d1 p( J$ w7 T+ o      xMax = window.innerWidth;6 U$ G7 t1 t& G+ t! ]6 S0 V- h, U1 y
      yMax = window.innerHeight;
% [! z6 s! y. [0 Z      contentWidth=document.supertext.document.width
5 u. K6 f1 U* ]/ q" @0 t      contentHeight=document.supertext.document.height# _7 J; n$ F  E. V) j; y8 W3 C% `
      document.layers["supertext"].visibility = "show";% d1 \. l2 u5 l' x2 I
      }5 e% n# X! b9 m* e2 v6 o3 a. `
   setTimeout('moveBall()',400);; |6 @3 D* P. H: B. \) D' d* U
   if (hidetimer!='')
; k! x( z' }! y$ L! z1 ]0 i3 R7 \   setTimeout("hidetext()",hidetimer)
4 R8 ~* j7 O5 e8 U/ B+ C   }
3 X2 T* X1 d  C) ?7 N; [" p; K7 \9 e  X. R
function moveBall() {
. R) ^& S& u, Y  z3 b: z   if (superballRunning == true) {+ P7 P7 @: ~: \+ g3 {& K
      calculatePosition();  j" J, a& M# Q, U, ~) B
      if (document.all) {
) L' ~% g' V5 ?* ?         document.all("supertext").style.left = xPos + document.body.scrollLeft;# N* p/ }. l( N) C: L4 t
         document.all("supertext").style.top = yPos + document.body.scrollTop;
2 U+ z( O& \6 F% ]4 e& J         }# V+ \& \0 P4 p8 F$ u1 ^" V
      else if (document.layers) {3 }- L) Q8 H% G/ D: t% I( o
         document.layers["supertext"].left = xPos + pageXOffset;
% i% A! W# k) u         document.layers["supertext"].top = yPos + pageYOffset;
! j! @* B: r( u& D* J: f: Z         }
/ F0 L2 h) b$ a+ C1 {3 h      animatetext=setTimeout('moveBall()',20);2 ?* o" C, C" A$ X; h- x/ `- h
      }; p$ E( j& U+ ~- j6 O
   }8 S% S2 e$ a( R# U0 c' P( z
  @) v* T! N4 Y$ S4 @
function calculatePosition() {- x/ }2 i) u6 z4 L! E3 E
   if (xDir == "right") {- z8 n% x) k3 G6 C* f3 w& ?3 c) X
      if (xPos > (xMax - contentWidth - BallSpeed)) {, w+ e2 E% u0 @7 d/ D' E9 W
         xDir = "left";6 v% d3 Z/ P; F6 P6 O; }
         }2 j+ p  `: Y, s2 N9 v
      }/ |$ ]6 @4 j  I  |# `5 F( }! C2 K
   else if (xDir == "left") {8 a, ~" z2 {5 Y* L
      if (xPos < (0 + BallSpeed)) {
' q2 K/ O7 y' N         xDir = "right";/ B9 S! x. T- A1 r8 ?8 g6 Q
         }' {7 y" }7 q) [
      }
) f  u8 [& b$ n   if (yDir == "down") {
; U' ~" `( W) @; R' s8 S  f      if (yPos > (yMax - contentHeight - BallSpeed)) {: G0 x! ^. A3 S
         yDir = "up";
$ E' y# ]6 T, D" ^5 @1 ]         }5 c. k8 B6 m4 i
      }" ]" X* M8 D" h4 B5 v+ H. B
   else if (yDir == "up") {' j8 `, N) s/ e/ Z% v7 _& ?
      if (yPos < (0 + BallSpeed)) {
0 E0 @* r* c. P& U! x: b         yDir = "down";
$ V. m$ ~2 n7 y9 [8 [         }( P# |, C: t8 H7 s1 O
      }
' x. U/ |- b% B5 u. B' }' ~9 z   if (xDir == "right") {! H7 O* z" C" f3 ]  @
      xPos = xPos + BallSpeed;" \. N! b% M) G: K0 D5 V7 K
      }
4 F" c9 |* r; X  j- B   else if (xDir == "left") {& m9 a( {2 v: w+ Z. u) Q0 D% Q
      xPos = xPos - BallSpeed;
) Q5 }. ]# S. P3 {- t, [3 D      }
0 v% J; {! f# j) A: m. U   else {
( C3 |7 \* \/ e' f+ ?" a      xPos = xPos;( x; w# d: m6 f% d" A
      }& V0 J! R! a; c
   if (yDir == "down") {
- G, l. G3 V9 r0 b0 w1 s" e      yPos = yPos + BallSpeed;. c+ W& `- d* [" C9 C
      }
7 T( I5 N$ T; |) W: d9 k7 `. S% T   else if (yDir == "up") {
, f5 n6 O8 g* }' d9 k" ^0 a      yPos = yPos - BallSpeed;7 X' R) i& k0 l, }  r- n9 B3 Q- q, f3 J
      }
4 f9 P" p& C% l$ Q; h5 X& f, }" ^   else {  U  ]+ @+ v' ]) Z0 c
      yPos = yPos;
9 _; j5 ^/ D" s* Z  V/ `      }
. [$ Z0 P6 K, E+ y# K2 n& a   }
( L, t; S0 s0 A' X& O$ h9 \) t8 ^& H5 G& z" v0 J0 l9 J
function hidetext(){
, s& r! A3 P! |* C9 P. @if (document.all)! n/ ^" t. K1 ?; a
supertext.style.visibility="hidden"  x/ R5 d) z- t( o4 E2 n
else if (document.layers)
2 [' k8 I' [# s1 udocument.supertext.visibility="hide"
6 a6 u/ \6 F0 j; a: b2 g1 q" ?3 ~: jclearTimeout(animatetext)
* r* t5 _3 h! R/ O+ F}, x8 _5 J( S& h* C; |

/ S6 m# Z  e4 Q8 ~" oif (document.all||document.layers){
! q1 f% g# y5 Q* Zdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 J) @) O4 L: G+ M( Q  ]0 h# C1 A
window.onload = initializeBall;) l4 ]3 ^9 f, G3 n1 t  q
window.onresize = new Function("window.location.reload()");
: g8 ?  a+ b' S* z2 E1 @$ D) J}
+ g8 U4 u, q# E: G+ m6 J6 J- V$ L) K+ V& A. A6 R' ?" j
</script>

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