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

|
网页之不断弹射的文字-特效
<style type="text/css">
2 _7 |4 q" b r#supertext {
0 h) }7 b% z) A5 Mposition:absolute;
# C, r. p5 {4 w7 ?# L# M8 Cleft:0;
1 T; P2 a# F: k5 utop:0;
6 R" h7 e( F( m( Y, b& D6 Gvisibility:hide;
( w- K N% S$ A: J! u9 Y. Ovisibility:hidden;
8 t7 [5 d/ ^. j- l2 k D6 _7 s a}+ g7 V4 a: c. v' }
</style>9 D6 O. [& k1 ]: H5 |7 F2 h/ s
<script language="JavaScript1.2">5 p) B0 g- V0 Q- T
<!-- 改变下的字体的大小。颜色-->6 D" {3 H' f5 C$ B
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'! |) p# u3 @% d
var hidetimer='';
" i! _- k. B5 d2 k, l3 Q$ k. J<!-- 改变下的弹跳速度-->
0 d- r: a; a, z+ k; Vvar BallSpeed = 20;) W/ f6 t" c% _+ E/ I g. i
var contentWidth;
: s- K i' P9 _4 U0 Evar contentHeight;7 C. W9 I1 W2 E2 u
var maxBallSpeed = 50;8 A# U6 q M, t# ~5 Q2 O+ B
5 Q1 D0 n' h2 o1 H0 B1 x C8 |: b0 d9 L& ?( U
var xMax;# [ t4 U% i# M" E' B7 ~
var yMax;% e8 X; [! z' f2 z, S3 D$ k! }
var xPos = 0;. z& |% C9 [0 V; P5 @
var yPos = 0;
0 C3 S% }' S, Mvar xDir = 'right';
! i0 e6 g m7 p# y/ ovar yDir = 'down';) T1 B# I s. H" E
var superballRunning = true;
+ o" H6 O1 ~& Q. svar tempBallSpeed; Z4 c7 V8 a. v& L$ k% |
var currentBallSrc;
1 r! n m, b9 p; I) g rvar newXDir;) _* p1 v2 b1 ^' {3 w
var newYDir;' e& c" M0 X- ^. ^: _
! K) J) T2 {" [7 n& F, u) X" x
function initializeBall() {
# ] ^1 n6 p! @5 q# l if (document.all) {
7 N8 K6 D8 Q0 _; V! x xMax = document.body.clientWidth
) V1 [- `; c% q1 z; q yMax = document.body.clientHeight4 x- m( N4 K! k0 E
document.all("supertext").style.visibility = "visible";( v9 u/ h+ ] A/ `$ f/ I! e% s3 H: s+ Z
contentWidth=supertext.offsetWidth
* j" B# @& Z0 w* ?& u contentHeight=supertext.offsetHeight9 \+ C* H7 s, K* o0 _
}! k! c4 S: v5 R1 V9 v1 r! z
else if (document.layers) {
. B5 }, `# F4 t- e: ^. W( L/ F xMax = window.innerWidth;
, _! H# i! c! D6 B" U yMax = window.innerHeight;- u, o6 z4 c5 h
contentWidth=document.supertext.document.width% P% q+ C9 f1 O3 O; {
contentHeight=document.supertext.document.height0 J3 y+ T/ ` |3 j( ^
document.layers["supertext"].visibility = "show";
4 K4 I& U' C3 C% ?) p' X }3 ^* R$ n a4 `) X
setTimeout('moveBall()',400);3 Y8 P8 |9 D$ N' h
if (hidetimer!='')
! `: v( K' M) b- R# a% m/ ~ setTimeout("hidetext()",hidetimer)
/ x" |9 ~* R# j/ u+ x; n9 g6 V }
. k2 z3 g* t! J) F) O& `2 ^7 y) x2 I {9 C2 `. Z
function moveBall() {
. e4 O! f+ ^: M2 Z! F: u/ I if (superballRunning == true) {
/ ~& j9 b3 A$ {- g calculatePosition();
- u% |0 N& e$ r2 b. S% [ if (document.all) {
; Y+ n9 m8 z; l Y* Z/ T document.all("supertext").style.left = xPos + document.body.scrollLeft;
1 V( p: j7 i' d- c3 L! b: S document.all("supertext").style.top = yPos + document.body.scrollTop;
" N% t4 e! j3 G- P# X9 H$ [ }
7 `# j' i& G( K: [ else if (document.layers) {# u" Y8 c* [+ t7 b3 G
document.layers["supertext"].left = xPos + pageXOffset;9 |& E5 _. w! k6 \
document.layers["supertext"].top = yPos + pageYOffset;: V7 {' u- G& t% H2 z/ A. @$ C
}& J3 \% `6 N) z+ T
animatetext=setTimeout('moveBall()',20);4 p) Q, [$ e3 W- M z0 _. b
}4 m& d, M* _4 e0 ~
}7 ^& p- J, E5 x8 I0 z% F! Z. D
+ y) i! X( n5 U: o! b- ]! r$ |
function calculatePosition() {
$ p! [1 ~3 B2 u" B6 p if (xDir == "right") {
/ H: m6 [7 `, k7 e2 [. d& ? if (xPos > (xMax - contentWidth - BallSpeed)) {6 ]2 z9 @7 }7 A* W! I) W Z% ]
xDir = "left";. f; v. n' j# o4 K% r" N
}1 a4 A1 [3 T# `7 Y& ?
}- X1 E5 U8 k( x' z% g! B/ S
else if (xDir == "left") {" P* p+ S. z# Y7 T2 P- d
if (xPos < (0 + BallSpeed)) {1 Z, F- Z8 E$ [7 u
xDir = "right";
) ]/ [3 q2 m- w7 B$ G7 K0 V }4 }; `) u- t- J4 t) W* _
}7 v7 x+ C- g9 y4 q( \ H6 s
if (yDir == "down") {
0 Y! R+ L$ d, J) h! I% ^ if (yPos > (yMax - contentHeight - BallSpeed)) {% f, ^2 M% c4 b0 V" z
yDir = "up";2 }' }1 O1 h3 @/ {2 I
}, J& t/ z+ x9 n* q- S8 T# a" h
}
/ T% E" C c4 ^! Z o, h8 v else if (yDir == "up") {0 m" _+ K8 l' z, j, u
if (yPos < (0 + BallSpeed)) {& O# z4 E& x) C, ^% H6 x* k+ l" e( W6 F! z
yDir = "down";) k4 f2 D! t# H( ?" ~" y1 g
}. _6 D" F" P6 U2 N# s* D) ~6 ~
}
p, B( W9 }# ?! f if (xDir == "right") {
; A1 y! l% Z" S H! e: M6 n! n, b xPos = xPos + BallSpeed;
9 i7 _" ?4 R- F* w' W$ Y2 Q }' y9 t$ F9 i6 X7 M* ^; L" ^7 P3 F' h
else if (xDir == "left") {! q; ^- Z% m0 t8 }( E2 ]
xPos = xPos - BallSpeed;
' t; R" m9 ^- \) {) @ }
# N# J: O- c1 {! c s, z6 z else {
% G5 _! q0 Q) t, _0 G xPos = xPos;
Z) z4 }; }1 l) c+ }9 n: v }
" \( k+ f) i2 {& f if (yDir == "down") {
0 Q4 ~0 l* }8 w3 X" K& M; {& v; B/ @ yPos = yPos + BallSpeed;
7 n! H9 @- L Q }
0 b) {5 `" e/ |# S else if (yDir == "up") {
" E( i0 f5 i& P7 h. H% t yPos = yPos - BallSpeed;' c: ]5 D$ N) o i
}' C1 p3 ^( x/ ]# ] M" I4 R8 f/ P! K
else {1 o# Z/ U0 p0 q( F
yPos = yPos;
: S- F1 [4 \' N }& Y+ V V2 S/ C4 d" s$ j7 S5 O
}
9 t' ?4 P3 \1 [) e
' C I3 Y+ f- z) V% Cfunction hidetext(){& H! K3 I0 f1 \
if (document.all)
9 L# z% G, s( {6 v. ^3 v. G2 i$ ] Msupertext.style.visibility="hidden"& w7 _4 z" b! U9 H8 w \5 ~$ i8 [1 C
else if (document.layers)
" U( g5 `+ R& O4 Y9 Q% Rdocument.supertext.visibility="hide"2 ]: e# \: }9 ~8 f j
clearTimeout(animatetext); I0 \6 E' d% k* B2 W o' s% {# [4 k
}; E( p" q& z$ |: s! |; A* H
5 P* a. t0 W* @6 ?; K* H5 X& _5 e: Q
if (document.all||document.layers){
+ D& z4 }' t! Q, Gdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
5 ]3 w) V6 x9 o( Z% C2 A% Fwindow.onload = initializeBall;& s) |7 [8 ?: `, e2 H
window.onresize = new Function("window.location.reload()");5 r1 {! B* W4 S' o% |& Z: ^$ F
}* X" e% Y9 f2 g+ s, M
5 q6 S5 ^% w5 ]. P& ?$ ` g</script> |
|