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

|
网页之不断弹射的文字-特效
<style type="text/css">: ~9 |( [, x! W
#supertext {
4 |* |7 E9 N- [$ |7 C( g% Zposition:absolute;( Y$ ?6 [$ g, U. ` A
left:0;* w: `6 y( j# m/ F9 |
top:0;
" w4 u E, b, t% B8 o8 Tvisibility:hide;
. s- M1 ~( F8 U1 M3 Q) _) _+ }; u! A$ Lvisibility:hidden;
& G0 M5 o) i; {- x# y}
* @) X7 m/ T3 {9 j$ s</style>2 H; B$ z5 \$ d$ f5 {7 i
<script language="JavaScript1.2">
" V4 d' @1 A/ h# H- v' K<!-- 改变下的字体的大小。颜色-->
& }/ U3 r G1 ~8 y8 {4 fvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'6 G- j+ H( k# f* Y8 o6 J
var hidetimer='';
# {3 n$ t& V5 s4 O+ @ L/ p( x, i<!-- 改变下的弹跳速度-->& e! M* ]8 c7 W; I
var BallSpeed = 20;
7 M/ }- ~3 g0 R i4 g& Z2 A9 Fvar contentWidth;+ R; ?: _* h( x* }1 N
var contentHeight;. K: ?0 H5 v" e
var maxBallSpeed = 50;
$ [& u2 `) B5 D+ a, i( k! ^2 f1 _( J7 }1 a1 p+ Z* i) t0 D
) M" r" j6 a Q5 ^; w$ b5 u# mvar xMax;
0 U/ z* p6 w9 \3 ^var yMax; y% u) R5 |/ l4 N, A6 W1 U5 Y ]- g" W
var xPos = 0;
4 ?7 I& r- s1 |, A, A# t- s2 s( evar yPos = 0;
# ^$ y- n1 ]. s, L) Bvar xDir = 'right';+ m7 i6 H: u/ K, {) b
var yDir = 'down';
$ A; c# n! l: ^var superballRunning = true;# \9 m% p( r0 Y/ P* {. x6 K
var tempBallSpeed;
, F# J+ E7 B. E- ]3 nvar currentBallSrc;* @3 ]; l* d K, A6 Y
var newXDir;; I, T* L8 t* a) K3 e, R
var newYDir;) l7 b, ^8 ?8 }
2 e! N/ | _, Y1 C, E1 o6 bfunction initializeBall() {3 W. O( b- ?* Z9 Z- Z$ J
if (document.all) {( k0 q, y# b- m4 }* v: ~4 R
xMax = document.body.clientWidth' d0 p w) }6 ^0 e
yMax = document.body.clientHeight
7 {. @" o" L& `2 u a document.all("supertext").style.visibility = "visible";
: P e) _! m$ p# z$ z: z- ~9 O contentWidth=supertext.offsetWidth$ D! p$ E% g3 o& `' k0 u7 h3 X% x
contentHeight=supertext.offsetHeight
5 m6 J3 g$ }7 o/ ?: Z0 r }4 b; N/ d* ]# `7 s
else if (document.layers) {
$ ~% u% R& `0 r9 U# X1 P xMax = window.innerWidth;8 W% w: J6 w6 m! V$ |
yMax = window.innerHeight;
9 M: t7 s5 C1 z: a% I5 L) C contentWidth=document.supertext.document.width
; F: \5 n9 e* P) |7 W7 `$ z contentHeight=document.supertext.document.height
) F8 j1 ]* u8 \( q1 l1 f. [ document.layers["supertext"].visibility = "show";' {2 n( C4 v. f6 U) e1 |% h& P# l
}
! M7 e* n' M5 `' Y1 D setTimeout('moveBall()',400);
( W; @+ C& J. i1 [& i if (hidetimer!='')! s- j2 s0 d1 V# v0 j; ~
setTimeout("hidetext()",hidetimer)
4 v" j: s$ c1 h }+ b0 r& e( s+ i( u3 g
! S! _; h# p" X7 Qfunction moveBall() {: X6 }' j$ ]' b% T% b" r( S6 M$ \
if (superballRunning == true) {
. c/ j' M7 n8 z r9 c calculatePosition();- |. w7 T" X4 K) l
if (document.all) {
0 j2 e! l+ t. A* \. v document.all("supertext").style.left = xPos + document.body.scrollLeft;
/ ~& Z# U7 k9 h; q document.all("supertext").style.top = yPos + document.body.scrollTop;. d; {7 G$ l- C* W: K- m
}6 g9 A" o$ g m9 X" r
else if (document.layers) {
- b' s" c3 @) {4 b5 R* i+ u5 B document.layers["supertext"].left = xPos + pageXOffset;$ Y* Y! V5 R) S" z. A2 ~8 f
document.layers["supertext"].top = yPos + pageYOffset;8 `' v5 b a* U7 c# ]
}
. C q' y! N; h animatetext=setTimeout('moveBall()',20);: h9 W- U9 {% H) X% _0 m% }/ X# I
}
, J: w1 \( Z4 ~2 A( j1 I9 l }( X |' _6 R4 N9 f
: O7 w+ ?2 K2 Z3 S3 Nfunction calculatePosition() {) W. j% Q! a7 W4 q5 ]
if (xDir == "right") {
. M& W5 W; H4 y, O* w' Z( B if (xPos > (xMax - contentWidth - BallSpeed)) {% V# t+ A( W/ u/ ^2 c G
xDir = "left";! P: Q' K+ | H, B, n D# p
}9 `4 ~+ k7 x/ `" Y% J M
}
+ `% ^! R) N- c7 e+ ^. T' ? else if (xDir == "left") {
( h5 Y+ }: ?' Y' F if (xPos < (0 + BallSpeed)) {
7 V# b( H7 L6 G' _$ e xDir = "right";
6 X% T8 X, B# n4 t% I ^) ~ }" _4 `9 D9 ]5 R7 G, {2 Q
}( E; ]# `. M% `- m" v
if (yDir == "down") {' D! b( C* T2 D. I; h0 N L9 v7 t
if (yPos > (yMax - contentHeight - BallSpeed)) {
8 n; L# O% d7 i8 P yDir = "up";
5 O) q& T2 o: [) o' S+ U }# b" b" J2 f+ w9 o* |: a; D" u
}
& u& F- [- \8 P2 i$ ?) } else if (yDir == "up") {
) o# S% t! T4 b, w4 f if (yPos < (0 + BallSpeed)) {
+ T/ s4 d& @- u3 k- s7 X4 N% [ yDir = "down";
, A: t3 p3 n X) H0 q" V4 k" A }9 [* I; _0 g; F7 g% D
}
% P' D \/ R- M3 d) {$ `" R: Q7 w* d if (xDir == "right") {
. b& l8 ?' l$ W; b xPos = xPos + BallSpeed;7 A* d3 O. d& I( i/ f( q8 L& M
}
' @& E/ n) y5 \' \8 e/ |; J else if (xDir == "left") {+ c3 I3 ]2 _+ U' W
xPos = xPos - BallSpeed;) `3 q- L) ^) ^
}) J% M6 X' @6 w
else {( B" m! o# W0 k5 Q3 {0 C
xPos = xPos;4 s/ Q. \9 i. A/ ?
}
6 i+ K# s7 ^" Q: ?9 f+ p3 e if (yDir == "down") {
7 L% z' B5 ]: I* j/ k x7 C+ R yPos = yPos + BallSpeed;9 i+ F1 G4 o5 f
}
; l* j+ h) o, O else if (yDir == "up") {2 R& K4 j$ `7 _9 ]) t5 s3 y
yPos = yPos - BallSpeed;
9 J. k2 v, T) H, N }
* H$ m6 `; Y) m4 ^2 d- a( @1 k else {
5 } I+ t O7 I* _, U yPos = yPos;4 p* @2 L* f+ a2 z& x9 L4 U6 \
}
+ k' Y( \9 ~3 |; S% M }
- w. `: P5 R; ^2 |) u3 O- ~+ _% F# {3 T8 M3 Q" b- q
function hidetext(){- i9 e" u' _# y5 p% q0 w
if (document.all)
' [0 K0 d+ l5 X/ i0 k7 X) p3 rsupertext.style.visibility="hidden"& q6 o- g& j/ K. @* `2 v) P
else if (document.layers)( i+ g7 l1 @' \; m
document.supertext.visibility="hide"
' e, u6 m* R+ S- Z# ]* ?clearTimeout(animatetext)
, Z: M; L6 \7 t, c- B}+ { H2 `4 q) I. I
Q, {& z1 o9 @! ~4 wif (document.all||document.layers){( X3 @; i( n O
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
8 W! k. U" m, K" i2 f4 Ewindow.onload = initializeBall;# k- [8 u" M& o* P# o. T8 {7 B4 U
window.onresize = new Function("window.location.reload()");
/ n y# l* ?9 Y7 {; B! s}
4 }; k/ z8 U" f0 W. U
, P9 s0 J9 v7 M8 |</script> |
|