|
  
- UID
- 133
- 帖子
- 51
- 精华
- 1
- 积分
- 186
- 金币
- 55
- 威望
- 2
- 贡献
- 0

|
网页之不断弹射的文字-特效
<style type="text/css">
7 a3 O1 Z/ ~; p, d$ z/ S9 _! p#supertext {3 K; O4 ?0 _6 _! j
position:absolute;
8 y; c4 s+ F& q' M! cleft:0;' U* x- z* y6 J" ]" |
top:0;
c* e! l1 N% \& Y2 Z# w& [visibility:hide;( {8 K) @0 \$ S/ t# p
visibility:hidden;
# ]$ E' Q; D5 g5 b}- w% H# `& K" l2 n, _5 A$ y
</style>
+ L# _; T- {) N0 _, E2 _; m<script language="JavaScript1.2">0 O7 Z; L8 `5 z! Y
<!-- 改变下的字体的大小。颜色-->
( b5 y$ l7 K1 w- a3 V# Fvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
' ^" e" l* N1 l7 Y; Q+ }6 gvar hidetimer='';- B- ^: E4 E* i
<!-- 改变下的弹跳速度-->
6 ~1 f" \3 J( w" a8 Cvar BallSpeed = 20;# H7 V* {5 A. y) I( y
var contentWidth;
$ w3 V) F/ q0 c7 ]* ?var contentHeight;7 Y+ Y( e4 A M. k# I& Q% m4 Z
var maxBallSpeed = 50;+ j+ x* r' @/ N J
! a1 S7 c* Z) g4 f6 N6 L$ i
6 ^/ A( M1 T/ N, v9 A
var xMax;: b( [5 G- v7 g4 C
var yMax;
$ V0 w. }7 S' u: nvar xPos = 0;& ^$ [6 T8 k5 v- f2 [* H9 b
var yPos = 0; a0 f7 _- G' y+ R; [8 b$ b
var xDir = 'right';; X; q; w+ O0 G5 n( Z
var yDir = 'down';
6 X+ j' C6 e8 `1 U6 Fvar superballRunning = true;- \/ J+ e9 o! x1 E# T3 G9 Q
var tempBallSpeed;8 G# D4 W, @' p/ k
var currentBallSrc;2 I9 B6 ?" ]! |5 P8 C5 o+ I/ y
var newXDir;# P% G2 r5 v9 ?) d
var newYDir;
0 e5 a3 M7 \. W. l8 P, K0 z; X# x& @, Z# j5 V
function initializeBall() {
, b+ _3 i. X, c3 X7 ~ if (document.all) {: `: O9 O, o" W, T) b$ h- e
xMax = document.body.clientWidth
# Z* K, R: h. t$ L1 h+ d$ ]3 t) P yMax = document.body.clientHeight
3 h- P9 z* `+ E document.all("supertext").style.visibility = "visible";
" r3 O) z# ?: l/ n; H0 ~ contentWidth=supertext.offsetWidth1 \- U! _5 l W
contentHeight=supertext.offsetHeight
: R. |. J/ I- R/ o: ^6 R }: O5 v9 b9 o/ i9 k4 L7 `, l9 ~% p
else if (document.layers) {
W* R; v" y8 @- F. ? xMax = window.innerWidth;
- J/ j. x! T# r8 ?6 i% c8 z' g+ l* q, r yMax = window.innerHeight;
# A3 O2 i3 g( A. T7 X contentWidth=document.supertext.document.width/ K3 T3 C/ w' }* B0 ~( J3 e: I
contentHeight=document.supertext.document.height+ K3 ^8 T0 L2 t& |* @2 K9 a
document.layers["supertext"].visibility = "show";
( r1 Z" O, l* _9 B& A, D }
- y0 y8 Z( a; x* r' W! V setTimeout('moveBall()',400);
0 L+ w8 U {1 e7 E4 Z if (hidetimer!='')& P) g2 g1 G$ \0 c/ L' ]8 |
setTimeout("hidetext()",hidetimer)+ s9 ]& T& c% m- [& n& l- y+ O5 l
}: j. N. {8 e, p* C0 w2 T
U2 I0 _- `6 ^/ r9 D6 o
function moveBall() {
4 M" K% y; \, y% E if (superballRunning == true) {
' N5 v3 U# h% Y* O% k0 `2 b4 A calculatePosition();
! {' J) I$ K. F- T if (document.all) {- j$ n, N4 r) x" P& _8 p# O
document.all("supertext").style.left = xPos + document.body.scrollLeft;8 Y( [6 m M2 j+ Y& d( Z- Y
document.all("supertext").style.top = yPos + document.body.scrollTop;! q/ Z. I% r( \! k
}
4 {: ^, X4 p& `% V else if (document.layers) {
1 j. m; _0 O: j& d document.layers["supertext"].left = xPos + pageXOffset;
" T' L5 `! W; o* y6 u0 [# W6 o' |$ ? document.layers["supertext"].top = yPos + pageYOffset;
8 G( }9 M1 C1 d+ ^( d6 o0 r, C$ [6 A }
4 Y1 x1 b0 Z8 u9 S5 a3 H. h animatetext=setTimeout('moveBall()',20);9 O! E0 d4 U! _; x ?, S+ o
}
4 g& J# Z" R7 K& Z2 c% p }
3 X- e! g, T% E6 K( |7 \5 A W, U9 I) |" j$ J
function calculatePosition() {
, w) O. G' d% A& ?$ W. q if (xDir == "right") {* C5 |9 j# k/ ^. v
if (xPos > (xMax - contentWidth - BallSpeed)) {4 ~/ g5 ~5 w/ i- }2 H4 \# S
xDir = "left";
/ z1 I( u6 q* z) b- |8 } }
L! O) w& l4 ~' N }1 e( y0 c0 k" R6 @; s6 X
else if (xDir == "left") {9 R; ^( X, f7 K
if (xPos < (0 + BallSpeed)) {! m$ B+ t+ c% ?" x+ q2 E
xDir = "right";
" F& v& I& Y' N: J/ t# D }+ C& T7 ]* O5 R8 B3 \
}
) [3 G3 ]4 f- b; r+ s if (yDir == "down") {
; `. I. D& }5 O/ a, |7 U; d! t if (yPos > (yMax - contentHeight - BallSpeed)) {
i: D5 {2 x3 I- c/ Q yDir = "up";- Y0 P. @" e) ~" U
}& \; W+ A* Z5 B) t6 t9 B
}! \% S- ^0 i, X' e; Q
else if (yDir == "up") {
! r9 \8 S L" `: q* L b if (yPos < (0 + BallSpeed)) {
! s: J0 Y& A3 O6 `2 ?; M- P yDir = "down";
2 D0 e- q- d' C/ t: |0 P3 k }
9 F' ^3 ~7 ~0 c8 ]# V( Q/ r }
0 g; i0 r3 V' m6 H2 |9 H6 R if (xDir == "right") {! \2 L7 K. l( B S% v$ p
xPos = xPos + BallSpeed;
" a' q; N. i4 T: ~: m }. M5 A# c+ i s. k2 e3 r
else if (xDir == "left") {
$ R7 X( @- G5 U7 @" N" w+ [ xPos = xPos - BallSpeed;
% C2 _- i4 V, }$ v9 p, P }( Y3 ]- k: f; T
else {2 M% Z3 I0 Y: F
xPos = xPos;+ k0 L M; i3 G- p8 q
}4 D' V) O/ ]7 P4 n5 C0 Y3 e+ F* e6 }
if (yDir == "down") {
* d5 t# C8 m' l9 r# A" p ~5 p yPos = yPos + BallSpeed; B5 w% C1 }& o5 E$ ?. P6 n
}9 p9 u) _- j& M
else if (yDir == "up") {
& `+ T4 m! W7 w8 u, i! @' [ yPos = yPos - BallSpeed;0 Q4 f3 T% u0 r0 D3 Z" g
}
' K2 X! M8 Q4 R) h- h5 V) h0 M else {7 C y9 _" D" l- H% l6 f
yPos = yPos;: o' |0 C3 H; S6 l2 p# C
}
) N: I3 q' V0 O; B; A }" N6 b8 C0 t D% r: ?) H
2 d. l, _7 ~6 ]: {# n
function hidetext(){
( D! ?0 K) Z% t. \if (document.all)
. P5 y* z& V" j7 `2 xsupertext.style.visibility="hidden"
! t- m. W" L/ @& w, Q) K% {$ Felse if (document.layers)
2 s- W: W% c/ Hdocument.supertext.visibility="hide"3 r: X; E- s8 v& u
clearTimeout(animatetext)
6 ?/ @4 F d8 l- t6 m}" X% ~0 r% Z' U* e
S/ q. }1 f- A; F% B
if (document.all||document.layers){6 P1 |. g1 A( j- U. K/ o4 T
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')) Z& j m9 o1 F X8 O# L6 i
window.onload = initializeBall;
& y' O% p. k+ E' Rwindow.onresize = new Function("window.location.reload()");5 f- S# j" c0 `! Y$ p! n2 E
}
0 \1 M9 K3 W' r K7 e8 J6 J" _ r, T" I! r7 E/ V8 t5 v
</script> |
|