返回列表 发帖

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

<style type="text/css">; T# u3 z& Q1 E9 x# N, F* g1 l* C' T' G
#supertext {$ ?3 O- {6 z) F5 }
position:absolute;# l' ?: h8 r4 Z% |; ?. t
left:0;4 W$ Z# U2 x8 p$ U" I# F) O. }
top:0;
% W' |# s& h! Ivisibility:hide;8 @. u1 B% M  o9 I' q
visibility:hidden;
- O9 K( F0 Q6 p; H}6 }: W5 U% A$ N3 j2 r
</style>2 `8 d, }+ P! ]' k0 F
<script language="JavaScript1.2">% I3 A& e. S# c9 T" q% Y7 {8 H
<!-- 改变下的字体的大小。颜色-->0 m5 ^" ?4 n6 k, q& H
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
' ?! L3 U2 A" @; \/ F/ S3 Uvar hidetimer='';
8 ]/ P9 J) s9 w' T/ `<!-- 改变下的弹跳速度-->
7 P/ Y, g- c2 i  b! k* X: _var BallSpeed = 20;
- H% i- z3 l6 [, L0 v/ C: H" U0 `var contentWidth;2 |! }3 ^: l8 x& z
var contentHeight;8 O2 ?" f& h3 b/ `. f1 ]
var maxBallSpeed = 50;1 I( G4 c" k% U+ m
- I9 A% [8 B. a

4 B% X! i, Z. [) C! F( a( Avar xMax;# V3 I/ p0 C  M
var yMax;
" @' ^0 U7 g! \) N) |1 wvar xPos = 0;: b+ g$ r1 D6 a( R3 U
var yPos = 0;
1 A% D+ X1 o9 A2 \8 l- dvar xDir = 'right';
: J1 Q4 P5 @: Z' ?. A3 svar yDir = 'down';
# E3 i  X1 ?- k  S' ?/ C1 Mvar superballRunning = true;
* _5 b& N1 e7 t0 G& wvar tempBallSpeed;) U% `+ Y" Q, l% _. i5 B( d
var currentBallSrc;
/ P6 V- L' F. i+ x4 f7 xvar newXDir;; o: d5 n. R% M
var newYDir;* o- A" b4 B* M2 C* v; ^5 H% b2 I$ I4 E
. {- d" J6 |2 G
function initializeBall() {
# @6 H% x: v3 z. Z( h. i' Z8 s   if (document.all) {
5 |5 y  f. L' u  Q/ F; Q) N      xMax = document.body.clientWidth
4 N! V& l' l# Q/ {0 t# `  M      yMax = document.body.clientHeight
; [* R. M4 U& K: L0 H" Z6 C      document.all("supertext").style.visibility = "visible";
+ R' y$ @. b5 S: L. v      contentWidth=supertext.offsetWidth/ a8 b2 l( b; H7 M" ?5 @
      contentHeight=supertext.offsetHeight$ C! I* G' H9 z% Z: _
      }
3 @1 D! W0 m( P  \   else if (document.layers) {
- \+ ?5 @/ E9 z1 r, O5 z5 z      xMax = window.innerWidth;
! r5 g* u* E4 l! h3 X5 L# `      yMax = window.innerHeight;5 z: X0 o# o* Z1 X2 e9 t% x$ `) e
      contentWidth=document.supertext.document.width
' ^2 n8 x9 G/ F6 n      contentHeight=document.supertext.document.height; |) l5 s* t' n- |
      document.layers["supertext"].visibility = "show";* s% [4 E; ]  h
      }
- Y( O0 M) V0 s( h2 A( y# X! N   setTimeout('moveBall()',400);
" l* M7 q0 k- Z* A) z$ r   if (hidetimer!='')
. f" l5 ~3 X3 q8 s% X+ A   setTimeout("hidetext()",hidetimer)
4 K9 u3 M' r! Z! F& J8 I# U" g   }
' d) d, k# k! G3 D* Q) x
0 o: m* a& z9 P1 C+ Xfunction moveBall() {- r$ {1 L+ @: u: \7 b+ v
   if (superballRunning == true) {7 x6 v3 M- B! }" W3 X  a/ f
      calculatePosition();
1 @, n9 R9 ^0 W! U      if (document.all) {
$ ]9 H5 Z! a6 B/ g! b$ v& `; o         document.all("supertext").style.left = xPos + document.body.scrollLeft;
/ c9 |5 G! G4 E$ Z3 I& i& F0 Q         document.all("supertext").style.top = yPos + document.body.scrollTop;$ R2 J7 {3 l& y( ?# R
         }* h; ]2 M& J1 ]
      else if (document.layers) {' ~4 s& O; L/ I5 w% v: ~, }
         document.layers["supertext"].left = xPos + pageXOffset;
, B: B. c. d  x( G) q% o8 s         document.layers["supertext"].top = yPos + pageYOffset;" m, u. L$ L' j! P/ c
         }
. R# z$ t) b& [0 F- B6 W5 Y1 z+ G9 P3 h7 T      animatetext=setTimeout('moveBall()',20);
) L7 F( r8 Q  |- u. n9 w$ ^/ s7 ^      }
! o. ?4 V  f# K3 X/ {   }  s1 F7 W7 N$ C. @  m* _' Q

' p2 |7 Y8 `9 N' ofunction calculatePosition() {" |2 L3 k4 {% J
   if (xDir == "right") {
+ o3 ~$ W$ y9 ^      if (xPos > (xMax - contentWidth - BallSpeed)) {7 V/ W  x$ ~, u/ `1 f* m1 E
         xDir = "left";
, Y. v9 m+ `* O+ `8 d" a         }8 G9 N* x7 S$ J7 H3 u
      }
6 a: J+ j) i5 \9 b' T/ j- k   else if (xDir == "left") {. S5 Z1 m) a" c9 V) Q4 k: U+ V
      if (xPos < (0 + BallSpeed)) {
, H- H7 ~5 h& K# M/ y) ~! c0 z         xDir = "right";
# [" N* J) ^9 P" ]         }( L- O" z, w8 k8 A- s3 f5 i7 C- M
      }5 K  H7 s* @& m' j; S  z5 e
   if (yDir == "down") {3 T% I+ V9 C2 J; a7 K
      if (yPos > (yMax - contentHeight - BallSpeed)) {
7 K9 _2 ?6 f) r: E- a" g+ g         yDir = "up";
- `4 X& _9 y' j         }6 f5 i- r0 D4 k- v  v+ V
      }
) j- U. Q+ e5 _  W% U   else if (yDir == "up") {3 \; V9 ?9 S6 G, E1 N% v# I" x
      if (yPos < (0 + BallSpeed)) {, f' ^- @- n* H) G, h& K
         yDir = "down";
$ k: N$ r9 P, }. i) i) ?" L6 n         }; C3 w) a; B7 B1 D$ W/ \
      }
$ ~9 c% f- `% l1 {; Q2 R& A# ^   if (xDir == "right") {
' i6 d' I# d% x5 O      xPos = xPos + BallSpeed;
$ g( t# l; g  d9 V      }2 Z6 |: c" d: ~# ^1 l/ H
   else if (xDir == "left") {
3 I7 F; M! l% C, l      xPos = xPos - BallSpeed;+ L: t6 `" h+ Z" L
      }
( a) k7 v0 {  D5 D: B& V$ m# X   else {
- {8 {: n2 d3 k' W1 l/ g; f      xPos = xPos;
; p& C- s% L3 q1 {2 X, T& s      }
- Q" W& z! L5 Q/ K3 s   if (yDir == "down") {
" o8 ]" j0 T7 W9 m4 T; b      yPos = yPos + BallSpeed;
# S9 r: i! }& m! Y% F3 h0 r, h      }
! M: F* W( Q6 M7 L   else if (yDir == "up") {0 _9 Z# V3 X2 y: l
      yPos = yPos - BallSpeed;
& t7 _7 i6 i5 p1 h3 x9 ~      }' R! G3 Y0 _2 C5 [9 z8 J) P
   else {& W7 H# A6 X: e
      yPos = yPos;
7 ?, O6 V+ [6 L7 A      }
: `- T! d8 Z- W' O  }) G   }
0 o" K3 H( y1 x: @5 a% y) _0 Q1 B- S8 e
function hidetext(){
% ~2 ]+ T( f  y+ C$ ^7 }if (document.all)# }' _3 C# y6 h  |: E' z. g
supertext.style.visibility="hidden"
) S" b! H4 j% H/ I+ ^else if (document.layers)
) h' m- E$ n2 W  r2 a2 kdocument.supertext.visibility="hide"
4 f6 h( X9 Y% O/ N1 GclearTimeout(animatetext)
) Z! }5 V9 y- d9 H9 a  B7 l}
, [7 }  o- I" l' w- q1 p# \% U" D3 M8 y
if (document.all||document.layers){; W% t9 Z1 w2 ]  R% \1 c8 R% t  s6 t
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')4 D" `8 z+ N( [7 t+ w  a: l2 k
window.onload = initializeBall;
, i; E3 ?% l' Wwindow.onresize = new Function("window.location.reload()");
! ?" f# q6 G5 Z5 }/ _: A}- ]4 k! S. [3 F, I* R; b4 x: o+ l

. e8 G" a3 G$ E, Z3 H</script>

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