返回列表 发帖

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

<style type="text/css">
9 i5 W( r3 v: d: ~! ?6 X#supertext {7 e, {& {8 m+ _& m  d* x
position:absolute;! k' K# {+ n4 ?! x6 G* N$ ^
left:0;: M; T- C; ~1 G0 X
top:0;' u4 g, o. s# Z
visibility:hide;! h! {$ L9 l( U8 \6 S
visibility:hidden;. w1 i9 W5 |8 L
}' P; [" G6 p3 n& p& b2 g7 h
</style>
2 L3 U# I3 h6 A% r& q' [<script language="JavaScript1.2">
; W5 `5 n/ q; [<!-- 改变下的字体的大小。颜色-->* K- m$ U, \0 Y  g; X; g% ~$ ^
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
1 r; a: G% a$ {! H1 Evar hidetimer='';
. C( Q! R: }8 e- N/ Z<!-- 改变下的弹跳速度-->
/ U! G4 S- a: l: C+ v0 Wvar BallSpeed = 20;8 ?1 W  E+ g( N' o3 u
var contentWidth;
8 ~- ?+ A5 g! d' Y9 Wvar contentHeight;: `2 Q$ |0 Z4 Y& p6 i
var maxBallSpeed = 50;3 Q1 C$ O# b. M- V* `9 Q
4 ?0 _0 X0 B0 r! o
7 N# b  i# I) J' L+ X) L
var xMax;$ Q' g( X% Q* X9 D
var yMax;% s* r, p9 i) q  _: q8 a3 ~
var xPos = 0;
6 e3 O3 e. A: y3 X9 E. R# Vvar yPos = 0;
/ G) r3 J7 x9 r) K% K- jvar xDir = 'right';
: g$ M0 B5 M, K$ i5 i4 [+ Kvar yDir = 'down';
. ~6 d. @  k0 a5 l: C5 Bvar superballRunning = true;% J3 O( B8 a: E' {
var tempBallSpeed;
6 [* l2 D( G. f6 V4 a, lvar currentBallSrc;' P. h& c1 T+ P$ n. x
var newXDir;4 ^# v; I0 v  j6 _: B1 Y8 H5 E
var newYDir;! _8 {$ O0 |" ~7 i$ x4 x

0 T6 O2 y- F" @function initializeBall() {6 [6 ^' o' v# U
   if (document.all) {
; r. s" h; ]- W5 l      xMax = document.body.clientWidth
: G, Z( h& V9 \      yMax = document.body.clientHeight
" v5 E. h4 A/ L9 C# t      document.all("supertext").style.visibility = "visible";
* o6 ^; e2 ]; K4 k      contentWidth=supertext.offsetWidth3 l* m* b' j' Z. m0 C! S' l' }
      contentHeight=supertext.offsetHeight
) }) O% N+ J1 q4 j% H* P9 E      }
: j( x) x( r9 d0 h, l. X   else if (document.layers) {; B5 q, W6 {& q1 e- `, z$ u' I
      xMax = window.innerWidth;
% v7 d. G: \! E4 i. ]      yMax = window.innerHeight;
2 x+ J# T  P$ N+ z$ w: _      contentWidth=document.supertext.document.width
7 G$ R6 H% C0 }3 U0 V# ?/ N      contentHeight=document.supertext.document.height
/ x' R, Y) ?& k6 i* y: \/ ?      document.layers["supertext"].visibility = "show";
  X3 _: U: r; `) x      }# x6 b3 J3 L! ~. @2 H# J
   setTimeout('moveBall()',400);
0 Y, N( P" o- D& }/ v   if (hidetimer!='')
# @! b# n/ X4 \. s   setTimeout("hidetext()",hidetimer)+ i0 R1 k6 R2 C: }# Y) x! ^0 n" w
   }9 }) d/ j) P+ c4 p3 n5 {
, u  @& Q! M" z4 [2 r6 n1 R- x0 F0 o
function moveBall() {
3 U' a' F( r9 a( u6 U   if (superballRunning == true) {) \; G" C; P- Y
      calculatePosition();
0 G) w  z7 ~! x      if (document.all) {4 n/ F8 |9 L" C, C# Q$ Z
         document.all("supertext").style.left = xPos + document.body.scrollLeft;  `' e; `% Z, X5 K' v  ?6 l0 E3 \
         document.all("supertext").style.top = yPos + document.body.scrollTop;
' S5 {. A. g. O( }7 V5 y- }         }
4 n! Z1 T' Y7 ^      else if (document.layers) {* _+ s2 F  U$ k; ~7 M6 [
         document.layers["supertext"].left = xPos + pageXOffset;7 {6 G& v. C/ P5 H8 }
         document.layers["supertext"].top = yPos + pageYOffset;, \$ v4 _# b% |0 [
         }
$ P/ e* ^. z; ~- E      animatetext=setTimeout('moveBall()',20);+ x. ^8 v) x$ N7 |+ P
      }  E) j3 v" B, B
   }
# {( a$ T; e. D) G1 d* L( ^+ q* i( q# l1 v+ l0 \6 v  A
function calculatePosition() {
9 q( x+ f: j5 {   if (xDir == "right") {# Q) @$ a4 h1 G
      if (xPos > (xMax - contentWidth - BallSpeed)) {
( g3 n& w% N. p* D9 r. \  ]4 A( g         xDir = "left";. G  g% x7 `9 v3 o
         }
' g3 B4 `. F/ U$ N      }
6 h; Q3 Z) q% S8 Q' w' D/ `9 d   else if (xDir == "left") {
9 d+ s2 y) B1 W0 _/ o! D8 ?      if (xPos < (0 + BallSpeed)) {
4 P' W' C; X. t' S8 f         xDir = "right";
7 O9 z" S/ U# O6 m4 g1 h9 f         }/ ?0 b8 l4 V; n
      }$ _9 o  M! d% f1 P6 L
   if (yDir == "down") {
4 }3 o: \7 Z/ H/ Z. n* C% p1 a      if (yPos > (yMax - contentHeight - BallSpeed)) {8 `! {& c6 N4 L3 \8 v8 h$ G
         yDir = "up";
: }2 h9 A# ~( a$ f         }
, T4 x, V1 H% s      }
+ {2 J" s4 y. H& |% K, M+ G( ]6 H   else if (yDir == "up") {/ T5 b" L& I; R8 a( ~5 q
      if (yPos < (0 + BallSpeed)) {& N$ B+ [, i  t% N) q
         yDir = "down";
  C! J: [7 x" S9 F# @" Y         }
/ s7 Y+ z9 R6 D! ^1 M      }1 S  R- p) M! g% N2 b; U, S, h
   if (xDir == "right") {" P" H3 w7 O% b4 J
      xPos = xPos + BallSpeed;
% S' Z+ J4 \* \% f  E      }
: o$ D" `0 |: t2 H3 U   else if (xDir == "left") {
2 k' L* Q4 u0 Y5 G, i4 P9 O      xPos = xPos - BallSpeed;
+ N: H: \. d! {! @      }' X, e0 z. L) z; r  t( I
   else {
  X  [6 u8 y; i      xPos = xPos;
# H1 e8 c6 O9 {, F# d) Q$ l% P: ~      }
/ _* h& [5 h$ Y9 m/ M. i   if (yDir == "down") {2 A1 M+ w+ g1 G- `7 q( i7 Y
      yPos = yPos + BallSpeed;9 c9 {! _* o, H$ {- M
      }
" T9 W, F/ y/ u0 b, a   else if (yDir == "up") {
* _# E2 N; p9 V4 l6 P0 q( F      yPos = yPos - BallSpeed;
# ~$ K1 y& O) \6 H& M% g8 w      }" ~5 Q0 p3 i( q3 A8 t( b' U
   else {
5 J% \8 ?* j% y* z9 a) ^7 j* O7 z      yPos = yPos;" F& A+ r7 [& R3 Z* D$ R
      }2 M4 u$ a0 r$ n5 |
   }
+ L0 ^( r  ~# }& C  k& n- B2 Q- a  I1 r* i
function hidetext(){9 V  L1 O7 f" [/ `) K! r/ V
if (document.all)
  v9 k, A! B& F: hsupertext.style.visibility="hidden"$ j  R! l& Y- g3 G# Y
else if (document.layers): D& x( t9 c% {* F# `+ ?2 j
document.supertext.visibility="hide"' `- ?+ @7 S2 f6 E; D- x
clearTimeout(animatetext)
/ t9 z# S* t! `# C* D) o; F" L}
- P/ N5 T( D) b, d+ C/ p( C/ X- S1 j6 j# L+ x+ `
if (document.all||document.layers){4 ?5 }# c( L" n& S" n
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')0 u. A' [6 u$ u6 b- g- l# W1 _/ H
window.onload = initializeBall;
+ D4 M7 O  {0 Y* u3 N4 D$ zwindow.onresize = new Function("window.location.reload()");" p  R5 b4 I  k5 ]1 G: C
}
, G  ~; j  D$ f! u8 u- W* h3 M, p/ J, U6 ?+ f  G8 f7 B
</script>

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