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

|
网页之不断弹射的文字-特效
<style type="text/css">
/ G, J; R9 Z% v7 C) r/ b" i2 K7 b3 p#supertext {
6 o& n5 H0 H- U9 w" Q rposition:absolute;- R- o/ s* G( i' | U
left:0;
- ^; I/ ~) v1 _, Utop:0;
9 b1 m$ ^6 D! r! L' uvisibility:hide;
2 B( c% m) t$ v: C% ]visibility:hidden;
' J. }7 G( `) g3 \2 n}
' H- [3 L5 b: K3 T$ q% q0 K</style>; V. M/ x- u) L% b) i
<script language="JavaScript1.2">! X6 _! h; V5 K' F
<!-- 改变下的字体的大小。颜色-->
& \2 F: j, {) Rvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'1 O5 ], d0 M( R2 A
var hidetimer='';
, M/ P. `$ o- Y: ?5 g- f% d<!-- 改变下的弹跳速度-->
6 j5 r, [ f9 c7 p2 Z/ Q: y$ v$ {: ?var BallSpeed = 20;) E4 E. P. ?7 J5 B% V9 n
var contentWidth;% N+ ~4 S) s9 B8 z2 W* z
var contentHeight;
* e6 B5 D7 W0 {" r) {var maxBallSpeed = 50;
( @- @- S1 C1 g1 F0 E" H0 T' i3 X$ w
% M* }4 e% e$ H. e9 |. ?2 {, T) a, `, V& ~6 Q& n5 w+ Y
var xMax;' H% ]/ k( r2 _, w
var yMax;; A7 {% R W, J1 `4 k0 |# _
var xPos = 0;
2 T7 \( I5 e) j% Bvar yPos = 0;9 N* `# X& x/ S7 d, }/ q8 V
var xDir = 'right'; E+ k. s6 g" y6 ]( i( L
var yDir = 'down';$ C( e- T6 A" [/ F0 b2 J
var superballRunning = true;
* O& d# b# n8 N+ G! K2 w9 P& wvar tempBallSpeed;
( Z; L7 ` s/ D* d: U8 Nvar currentBallSrc;
8 a9 A) g+ ~; O7 B' fvar newXDir;
; p) h3 Z9 z/ X7 \% B) evar newYDir;
& H) E M* c# q+ h+ o5 q, V% M5 S, P l! v4 y
function initializeBall() {
, n9 x' G2 p3 N% V S1 R if (document.all) {' {3 b7 I7 o) d+ f: t5 @
xMax = document.body.clientWidth
+ H( q1 \- D/ E2 v yMax = document.body.clientHeight: D- b; _" w. h9 v* j8 u
document.all("supertext").style.visibility = "visible";* Q$ ^3 ~& k2 C$ t. ^0 y, D' E
contentWidth=supertext.offsetWidth. X) ^$ M( c- i" _
contentHeight=supertext.offsetHeight
2 ~* g( I% a) c/ j }
. G3 w: e% {& r& m5 u' r else if (document.layers) {2 I2 I5 u/ a3 {" T a. L
xMax = window.innerWidth;% P/ G, C; B' p1 n
yMax = window.innerHeight;
Q% v; q/ f0 J+ Z) o contentWidth=document.supertext.document.width) A$ h8 [+ {+ H8 f* f$ u% x
contentHeight=document.supertext.document.height
( z. v- ?9 d& A* j8 U! f document.layers["supertext"].visibility = "show";
0 O4 ~6 w& s9 ?* s8 C }3 V4 _" Y: [8 j" y
setTimeout('moveBall()',400);
+ Z/ h: Y' [ M3 J& b+ h3 S( W if (hidetimer!='') D9 N+ e) T& K$ T1 f% B) w
setTimeout("hidetext()",hidetimer); o% K. c* R9 K: A
}
6 m$ @8 P A/ r2 v$ B; r( ?0 u1 S- x4 z7 e$ `
function moveBall() {$ e1 s4 U* e. T; v: Q. L* K/ L
if (superballRunning == true) {* c( w4 y/ c; L! `
calculatePosition();
& b' `0 M8 Y- Q' ]2 k5 ? if (document.all) {; M, F9 e$ J# S. l9 }# D y
document.all("supertext").style.left = xPos + document.body.scrollLeft;. e# c$ I$ z& J6 k
document.all("supertext").style.top = yPos + document.body.scrollTop;, ?" M) r8 F: B0 z
}% K% F8 ]/ m* s( _# v9 O3 e
else if (document.layers) {, w4 Y% \2 E" D0 E9 D, q6 y
document.layers["supertext"].left = xPos + pageXOffset;! P+ U2 `* s, F. w' \& D8 v
document.layers["supertext"].top = yPos + pageYOffset;( U9 |7 B3 z$ h5 i4 ]
}( c$ W5 m, ^2 f# |
animatetext=setTimeout('moveBall()',20);
* U" p/ g* K. e+ o/ w: i" Y( h }
3 ]8 ^- ]( c' W }. d. g- Y+ T5 ]; v0 z' d% I' g5 G# V3 b
) C4 M9 ^- D& X2 t* ~% F& Y1 ^- U vfunction calculatePosition() {
( r7 S0 V. s) T- h' k if (xDir == "right") {
6 U( y# q7 x9 c: T# J if (xPos > (xMax - contentWidth - BallSpeed)) {4 s! ~* T& N9 F
xDir = "left";
6 |" G m: U' C0 d1 V5 S9 J }# M8 w' y2 F* k1 t2 E5 l% A
}
' E3 _& o1 b/ T& S- J' J2 Y else if (xDir == "left") {
9 L; ?6 `6 H' ~4 {' _ if (xPos < (0 + BallSpeed)) {
, I: h+ ^& u. r. ^% X% E N- Q' ~! D xDir = "right";9 H; {# I$ `, j6 b8 ?4 z4 ~) u0 m
}
% _; w" j& X; Z f6 G( u }; L5 N& d7 o. t# F3 t, i/ T! m6 r
if (yDir == "down") {
. o: n: R7 Y% G8 U% K if (yPos > (yMax - contentHeight - BallSpeed)) {7 S5 y$ N4 |+ M/ D
yDir = "up";
m9 t0 d5 l( ]8 s }, ~& E$ ^8 p( y, ^4 X
}2 d- |* w+ ~5 @5 q. g6 R( ~
else if (yDir == "up") {% [/ _1 P2 e) U |/ A& N# T
if (yPos < (0 + BallSpeed)) {
% H1 W! g, f8 m5 } yDir = "down";2 @5 P) A. w8 K
}
0 J( Z; h6 ~, C" w* F }6 G9 ^, D T. V" p6 C. c- s' ~
if (xDir == "right") {
% J0 ~- I7 G" {; Y xPos = xPos + BallSpeed;
5 _- H& \: q+ ]$ o }5 J) U! i% |( p5 m; }
else if (xDir == "left") {# E6 g) ?3 t4 T, p( n3 g7 ]
xPos = xPos - BallSpeed;
+ C1 r# g- N2 N6 I t) o7 a }7 Y4 ~) w: x! c5 c y
else {+ ^; j# K2 y# q s d ?
xPos = xPos;
+ i$ G; j' ^$ M8 t2 U k9 W }
( E. l( A* B1 d# ?3 N8 V( r5 l if (yDir == "down") {
: H8 ~; N# R# K8 A yPos = yPos + BallSpeed;% S* a% }9 H" L* Y: k8 ^' k
}7 d% I7 w7 k8 ?' |0 `1 |
else if (yDir == "up") {
, _1 J6 j' m- p& {$ p$ E! t) s yPos = yPos - BallSpeed;
7 H( ~2 d1 L3 `0 B }
8 T6 P/ v+ [, ^5 U' j% Q$ a else {
/ U! n3 H9 ?6 p) [5 o) b yPos = yPos;3 F: d2 h+ ]" n/ x0 D. F/ U
}
) L! m, \. h4 j }1 k. Y+ {+ e& x8 s+ S+ X& z# l
7 d( @! [" b% @5 s4 W+ ffunction hidetext(){8 l, L7 h q/ h. c
if (document.all)4 @# Z5 [! g& E4 |3 p5 t6 w) v7 N6 _
supertext.style.visibility="hidden"2 w0 t; Z& g! P1 V3 O
else if (document.layers)
2 I3 J( A4 i5 ]( M! Z& \! bdocument.supertext.visibility="hide"
; Q# A% ?" v- {8 r+ H' e9 q2 NclearTimeout(animatetext)/ B. g0 b1 l! q3 C% Q
}. p, c4 E, j% p: }+ }: l5 L
9 N8 T4 T Z: i& s$ X$ l# M ]
if (document.all||document.layers){
4 b$ Y" w$ i& `# _7 idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')" _& V% N+ _3 C; X
window.onload = initializeBall;9 N* J. ~# v/ D( {: d
window.onresize = new Function("window.location.reload()");
1 Y/ h% `1 ~3 @0 r5 L- g9 m9 V}; y1 ^2 i- v) n3 {; w/ p
4 A- U' M' I3 X
</script> |
|