返回列表 发帖

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

<style type="text/css">' P. _& }1 w% u. Z* P% _8 u4 X/ E
#supertext {
9 F7 R" N% c$ ]! }position:absolute;6 b" w8 u) _. X4 `2 c$ K
left:0;
3 `' T; J+ p  N6 H' r. ]top:0;
7 B: D' l' T2 R2 svisibility:hide;
3 C9 K% [6 }9 J8 x4 {; D7 jvisibility:hidden;
; e! B5 X1 d5 g$ C8 S+ z3 }6 Z}3 C, b  N! x6 V$ w
</style>
, }! F4 U) T; B  [9 i$ \7 _$ W<script language="JavaScript1.2">9 N0 p+ i1 I; G) P+ X+ o
<!-- 改变下的字体的大小。颜色-->: a( L" V4 I- `
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'2 H3 o  c8 c3 Q" S
var hidetimer='';
$ n; ?6 U4 n9 K, Y<!-- 改变下的弹跳速度-->6 d: B8 t; w( o5 Y: n1 t- w9 c. K
var BallSpeed = 20;$ t! G- `, v/ }- P
var contentWidth;1 U* h! _# ~9 c$ ~
var contentHeight;
2 u; b9 B. H+ G5 ~, {( ?3 }7 @var maxBallSpeed = 50;2 F' w' b3 f: `, Z2 p2 [

( Q" l' f1 e; g5 A' u  u7 _2 R& Z% J
var xMax;
" _. v0 [, R. e: X% Y7 yvar yMax;
% ~. @3 W/ c4 A- H) Fvar xPos = 0;
! V+ f+ ^  g  H( Xvar yPos = 0;
- Q, s9 Z8 ]9 p: l# Y; C% i4 t$ H( Evar xDir = 'right';  S# A; b1 B' w2 p. W. v' j
var yDir = 'down';4 [' o& t# d' z7 \
var superballRunning = true;4 P3 z! @! V) r7 h9 k3 n
var tempBallSpeed;
; v9 ~; u$ \0 c! Xvar currentBallSrc;
! Y" b; E  b* o( ?! P" ivar newXDir;" |& q: M" w! j  X- P4 h
var newYDir;6 o& B9 E5 M5 u7 M9 M5 H% ]

. a7 e# z; O1 u; t1 d  gfunction initializeBall() {" K9 _( h0 d! u0 q( z9 ]+ h2 p
   if (document.all) {! I/ G2 S" b# K) @7 g
      xMax = document.body.clientWidth1 h. a3 G- S! v. f
      yMax = document.body.clientHeight- @& |/ C/ r8 H4 a
      document.all("supertext").style.visibility = "visible";" _; h2 V; `" P% E+ T2 J! }
      contentWidth=supertext.offsetWidth( j# F' k1 T0 g& L$ E) P
      contentHeight=supertext.offsetHeight
! G5 G5 C* T, Y% q9 g) E6 {      }/ E- o$ i* E5 @$ V
   else if (document.layers) {
& A" P9 o6 e  }. w& Z- m4 {      xMax = window.innerWidth;
6 H+ P) @3 Z  y7 l% B& j3 v      yMax = window.innerHeight;- Z' B1 ~" _- N6 i9 H% w
      contentWidth=document.supertext.document.width0 ?; j" c* ~0 |) }; C
      contentHeight=document.supertext.document.height4 K# B6 F& K* Q" d. a( L
      document.layers["supertext"].visibility = "show";
. ^8 |  i* ]" d! c& B8 ?      }; h( ?2 T# D6 g+ ?* |( [# t# V
   setTimeout('moveBall()',400);
6 m4 ^! ^9 F, @( \$ k+ Y4 S7 x   if (hidetimer!='')* {9 ]/ ?7 S3 C& G, b" S, m( ]
   setTimeout("hidetext()",hidetimer)
: R( F& f9 r- u' |+ h. g   }2 b4 Y0 C- y  G5 v. h! k
4 c& Y% o2 l: ^- y* O% z/ t5 N
function moveBall() {
8 v8 L, ^, V9 x5 T0 L, o% v% u   if (superballRunning == true) {5 c3 T" D, {1 _0 U* w  m
      calculatePosition();3 L: m; w5 \$ C2 T1 q% T
      if (document.all) {" N3 ^3 B! e4 ]
         document.all("supertext").style.left = xPos + document.body.scrollLeft;$ V/ L. }: }" b% w3 Q. F( n; J' _4 z
         document.all("supertext").style.top = yPos + document.body.scrollTop;
/ }) y6 G$ b# T7 }5 i3 v         }$ x$ m( U/ |! f) |
      else if (document.layers) {
' y. O5 C' [) N. ~6 g: O         document.layers["supertext"].left = xPos + pageXOffset;
' }0 N: F0 g3 ]+ N         document.layers["supertext"].top = yPos + pageYOffset;
- s5 c2 H% p  s7 [6 R) n- Q         }
- s4 p/ \+ Y1 O& v, p' T      animatetext=setTimeout('moveBall()',20);
$ I* d( Y3 w" `) @% q& J! o  s; i      }
' X( t; I9 i& p0 A1 l; }! h; V( z   }8 x) R0 W7 b0 y4 @' W3 x
! k) o0 d9 T1 R" w: b1 G
function calculatePosition() {8 P1 v$ B3 ]; G6 B
   if (xDir == "right") {
" A' j6 Y) J" N" p7 z      if (xPos > (xMax - contentWidth - BallSpeed)) {4 A1 C+ L% r0 Z
         xDir = "left";
4 X0 m+ l1 H& b8 s         }
* h0 @" X% x% \0 J      }
3 q$ S" _1 s( x* W$ N9 e  r5 o7 E& @   else if (xDir == "left") {
3 s6 G) g& s% C! i- O/ L      if (xPos < (0 + BallSpeed)) {
+ W8 P0 a- y1 F/ D5 _0 K         xDir = "right";8 g- P! W+ z' Y' F
         }) T& L1 ]3 }9 b& c9 M) Q% ]8 f2 j" N0 I
      }0 a0 ?# y* e. q0 ^2 z
   if (yDir == "down") {
4 U( A' J9 t( a' o      if (yPos > (yMax - contentHeight - BallSpeed)) {' C4 X9 {1 R7 }- X
         yDir = "up";
& }7 G0 j( z7 f' j3 N         }" I( n* b7 T  V% U
      }# L0 ~" `& S% y( c7 |
   else if (yDir == "up") {; V4 O' W3 R. c2 M0 N3 p
      if (yPos < (0 + BallSpeed)) {8 p# P- ^9 |2 d: f  R
         yDir = "down";
" E* w) o/ ?  O3 _9 N" n( u" O- D         }4 F' j) z! ~& @( K8 L  ^' p
      }) Y$ e5 n8 A( Q9 V/ D
   if (xDir == "right") {
, f; E  _: w$ Z1 L. T% E2 \; }; T      xPos = xPos + BallSpeed;
) J8 A8 j- Q: W8 r. f      }
$ `) M" |; w3 G& [4 ~5 i   else if (xDir == "left") {) t' I) V7 }' R2 A2 k+ c
      xPos = xPos - BallSpeed;
4 d* |% x1 J' w: y      }; v. E9 f- \9 o; R8 A% b
   else {
6 V4 g1 y) c% n4 O% Y      xPos = xPos;  K; ^# {/ V# D
      }
3 }" s- ?. g* B- X   if (yDir == "down") {
3 G. n2 {; U1 @% [* Y3 j$ E      yPos = yPos + BallSpeed;) T7 t+ f0 B' @
      }$ ~$ v  w) F, p5 |" Q
   else if (yDir == "up") {
# f# d! D7 M( ^/ J/ m6 Q& G      yPos = yPos - BallSpeed;+ A, z1 G2 \2 G/ `
      }
7 j) d) |5 c1 X   else {6 u& [% V6 t8 O9 @8 S- E
      yPos = yPos;% x; g& t" {- G" Q6 Y' [6 P$ ]: E
      }6 s& \. U  q: A$ y. p
   }
8 M% a$ \" s- v) D5 U+ _8 [" L9 W. ?9 D2 T8 w3 S
function hidetext(){
% s* R( b' d1 x# e! l, fif (document.all)
/ n# R( x' }4 m: i3 ^supertext.style.visibility="hidden"2 [$ N& {5 s2 N- U1 e. f- j
else if (document.layers), v* N) E, \' r: f6 P# O
document.supertext.visibility="hide") J% ]" j0 m' q' S# x4 A' W
clearTimeout(animatetext)
8 T- p1 D3 e& Z: P" i}; w0 B7 a9 u- d, V2 g
+ Q' ?( H" U3 e9 p6 a; o
if (document.all||document.layers){
4 W! G, w3 g) q: wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')( r2 N$ C: K. ]; a2 F% ^- v
window.onload = initializeBall;
' N. J5 |: W: s2 iwindow.onresize = new Function("window.location.reload()");
$ @3 E/ ^3 S( |) D( y0 r}
5 Q$ j" J3 T3 S% ^
! R' a+ K4 q9 H</script>

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