返回列表 发帖

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

<style type="text/css">
' J  f* k4 j; W  Y7 ~#supertext {
& x" ^. q' B" r/ g& M4 z. gposition:absolute;
; j& j/ l( o2 A, O) u( Dleft:0;
4 S6 S4 A: U' a$ |# i  Ttop:0;3 P0 g: X! {: m# ]# x  u
visibility:hide;$ @5 |* i6 a& h2 E3 [
visibility:hidden;8 W9 U0 `" g' e: P
}' F) e3 ~4 M8 y& g: V- i
</style>! ~  I6 J% t: Q" F! J
<script language="JavaScript1.2">
7 t3 a7 M7 {2 X6 {# E<!-- 改变下的字体的大小。颜色-->. p! Q6 ?; a8 D% e+ _+ o
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% M* E$ R& ?9 W* @( Wvar hidetimer='';
) A8 w9 _6 \0 b3 M6 h. _! f5 b, k/ o<!-- 改变下的弹跳速度-->4 n4 ]: K0 b7 b4 V: s4 w6 V
var BallSpeed = 20;
+ O3 E$ b, B* G( g: W3 gvar contentWidth;
0 S5 F5 k- V! p5 ]9 C9 f; Y* lvar contentHeight;
% t% t2 u8 r, R# ^! ivar maxBallSpeed = 50;
: u5 {8 h- |2 R7 A" X; }* ?& E3 }- v* r: X! g
* ^9 v) W6 g& V+ s  J' C& s; T
var xMax;
: R4 p7 P8 ^4 [0 T# Vvar yMax;
, {) Y7 z; V% I. d, [var xPos = 0;0 R  D8 e3 \- M0 z
var yPos = 0;
6 F# n: _( E3 a2 J2 O# nvar xDir = 'right';; R& k# @1 u- V5 c; \
var yDir = 'down';
( I6 e8 E9 J3 r: \& w% q7 j* Svar superballRunning = true;
, p/ w& H4 Q# X. t& kvar tempBallSpeed;* n6 [% q$ a  a# ?( Y
var currentBallSrc;
: D4 R" H) [, T' X: uvar newXDir;
2 p+ J. r! b# f9 n' K: a' V9 |var newYDir;
$ \. q1 R- l6 Q' W! v" C& b- y, B, M+ m+ [
function initializeBall() {0 B2 W# e0 \) h
   if (document.all) {
$ c8 h. \+ w  ?" L/ D* P3 \2 c% k      xMax = document.body.clientWidth" i1 g8 M- {. `" U
      yMax = document.body.clientHeight
! |7 C+ n9 S; g7 x5 D# c      document.all("supertext").style.visibility = "visible";
: k7 b" t6 [2 ?( d% T" K& S      contentWidth=supertext.offsetWidth
4 D1 @% J, x' b" F( @, Q% @) B2 `      contentHeight=supertext.offsetHeight! d% Y1 ?* e/ A
      }" g" {. v* Y5 t$ Q, ^
   else if (document.layers) {8 o7 G5 _; [5 e. P
      xMax = window.innerWidth;
# Z3 o6 S3 k* Q. A' N! @      yMax = window.innerHeight;! r2 _6 ^" R2 u) w6 R) j5 O
      contentWidth=document.supertext.document.width! s" n) [8 j# Q7 _* s
      contentHeight=document.supertext.document.height. L. s# E5 M9 t$ m
      document.layers["supertext"].visibility = "show";. N- i# t1 I5 |, \  _' k
      }% l3 f9 N/ f4 z0 o3 O
   setTimeout('moveBall()',400);
; H' C  c( r0 n: _) |" `8 m   if (hidetimer!='')1 x! w. l3 ^# Y5 v% l& N/ E/ W9 A
   setTimeout("hidetext()",hidetimer)) l, g3 B0 ^2 {. v+ j4 A" z
   }
8 n- ?1 c* n8 y) i( v
& ?& t7 Q% a# G7 h" U" u$ Afunction moveBall() {3 ?. @3 K2 C1 v: t! v# D5 W1 R
   if (superballRunning == true) {
% ?& J" ~2 C0 C0 u8 M2 ^! ]4 Z/ g      calculatePosition();
& u, Z3 V- D2 E6 y2 v  o$ R      if (document.all) {
* v) N9 L4 r% e# o# t         document.all("supertext").style.left = xPos + document.body.scrollLeft;
4 T1 b, d0 U4 W" a: C         document.all("supertext").style.top = yPos + document.body.scrollTop;; b2 x0 ^8 C: ?/ a
         }4 [( t: R' d  ^9 |
      else if (document.layers) {
" y+ ~# p. `( k- Z  x         document.layers["supertext"].left = xPos + pageXOffset;: g# n2 j( }( c& Z# T- v
         document.layers["supertext"].top = yPos + pageYOffset;
! A/ ^0 M- L% |, o- d         }+ o0 U0 s) H! N, Z
      animatetext=setTimeout('moveBall()',20);6 R7 N% Y4 y5 G8 x$ E) J- l( V
      }5 N. q2 ~/ P& C- Z5 A
   }
4 B( ^8 c- `6 P! f1 @+ g. i9 n4 Z/ @, R: U* o! N# k5 U
function calculatePosition() {
/ S. {1 ]4 g" l, M* h( W3 S6 {4 ]   if (xDir == "right") {' j  f5 t. L' O; _
      if (xPos > (xMax - contentWidth - BallSpeed)) {* L; t* w$ ?  q: V* g" Z9 g6 Q  Q
         xDir = "left";
3 Z! T- I( q' q9 E, Q  u         }- b6 [% G& y/ z+ |! k' b& {% Z$ _+ V
      }! O1 U4 h  F& p: n2 s  J
   else if (xDir == "left") {
( W/ @+ U- x  O1 i0 i      if (xPos < (0 + BallSpeed)) {' I5 [2 W1 w, t, @- S( m* P% S
         xDir = "right";
. X% S4 ]& j4 M! ]         }
* \+ U3 |( Y, l; [8 W      }
8 k, r) Y& p; Y$ i. a   if (yDir == "down") {. e& Q' k: m; T. S, J
      if (yPos > (yMax - contentHeight - BallSpeed)) {
" r( |4 @1 P; y6 \) T         yDir = "up";7 h  ]# F, U. q0 \
         }% C' H" D' F+ q% {1 \; S
      }
3 @( M, m4 @" ^5 k   else if (yDir == "up") {  ~/ V% f. a4 L" A7 q, W/ [, z# n
      if (yPos < (0 + BallSpeed)) {
6 G( w4 p6 ~, }/ Y6 K! m% x         yDir = "down";( Z' ]( j* f: D) }) ?( [8 i4 P. P
         }
4 z" U& n* D! B# E1 P      }
+ J& A5 k; z  D" \+ V   if (xDir == "right") {
. w1 t+ n% ^! Q8 o4 ?- @  L, [: L      xPos = xPos + BallSpeed;
8 g5 ~, @: D9 v1 l      }) k) \7 `( i2 d4 j) L" d" i
   else if (xDir == "left") {' S! s6 ]6 ]% f; A! U
      xPos = xPos - BallSpeed;' g: ~' Z+ ^0 a! O4 b2 R7 v4 {
      }
; Q( @! w1 V. i" k8 h   else {
8 u+ a3 s$ g  t4 {  w      xPos = xPos;
' f, a% Z2 o( O2 Z      }5 G% z  X) z$ t$ I
   if (yDir == "down") {/ Z0 n# j9 F- q. |
      yPos = yPos + BallSpeed;6 Q4 q: ]4 s/ q7 e& e
      }
+ N) h; c/ w  h/ k) Q" {& W, n/ `' m   else if (yDir == "up") {; s! Q. E/ Z$ p  d2 C
      yPos = yPos - BallSpeed;
- h+ V1 b+ M9 H% v, V3 d2 K      }2 Z' Y: Z, K* F  H9 p$ \: e
   else {
4 q. c/ Z. X" \# @. m" R      yPos = yPos;' I9 [3 K4 I$ w! _
      }* _0 c; k9 ]6 u4 s( C# i
   }# M$ f) Q* \- S! Q+ w* g$ C
* e' d3 ]( e% b5 b- ?
function hidetext(){4 e; t! |3 B& n
if (document.all)% {# z) Q% Z5 c
supertext.style.visibility="hidden", y4 w* F+ f: y# M2 _% p
else if (document.layers)
8 K0 k) W2 I* V6 N$ v" L1 Zdocument.supertext.visibility="hide"4 Y1 M; l4 b9 X* W
clearTimeout(animatetext)
# x; X! z+ u+ {1 v) _' k}$ u/ R7 S; b; V% _8 ^$ X+ ^$ Y

0 V$ t% B* o( P, y; lif (document.all||document.layers){
* k+ L, \" o' J: P* U0 l( xdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')9 ~4 |# m6 ]8 m4 E7 _1 s1 W; c; H1 i
window.onload = initializeBall;( t* A/ I2 I* C5 |& h
window.onresize = new Function("window.location.reload()");( f8 m3 N" m9 i$ i
}
" J+ Q4 t* J7 z& w! [' o2 F  X# |  @" _: T; q
</script>

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