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

|
网页之不断弹射的文字-特效
<style type="text/css">
/ |7 f7 y: [: s#supertext {
4 {4 @: ?, c+ s8 u4 Lposition:absolute;
% q; o) w6 X9 j8 O) h hleft:0;
% T6 t; a* S: a1 r% I- ntop:0;* l& l$ t- w6 F" \& }: `1 X& W
visibility:hide;
; N+ I+ t& F! b6 Wvisibility:hidden;( ~0 ]* y/ E4 d) W1 r$ j
}
+ [/ N1 g( _3 m3 u/ N4 C2 Z4 E9 e9 V</style>4 `: M7 A* k: ], ]1 q9 ^
<script language="JavaScript1.2">1 ^8 _' s* K \& o4 r" k1 s
<!-- 改变下的字体的大小。颜色-->
. [! Q+ _2 {4 D k; u- b& p- Svar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
) T$ O* R# I5 D/ a' c3 K2 V, B1 Rvar hidetimer='';$ a! T/ m4 u4 ]8 n
<!-- 改变下的弹跳速度-->7 r4 U: T a9 k% r2 N: j- M
var BallSpeed = 20;* n& E9 i6 b2 F# k" S) v
var contentWidth;
' K; x6 W. a: W9 T5 Rvar contentHeight;% }2 c. K4 K; s% s2 d
var maxBallSpeed = 50;6 J" S7 J) @7 K
7 H: R5 @2 G* b$ c: o) x
7 C2 R$ X/ J; t |: A5 ]' ^var xMax;
- T+ U o0 R7 g7 L% fvar yMax;
X. \, Q7 Y# n7 G1 d M% D5 y" t( Cvar xPos = 0;: G' S; l. ?$ K
var yPos = 0;
- y+ I3 r2 Q( C' L: D% M0 S' c9 T/ Tvar xDir = 'right';
4 O, U( H3 S6 c( wvar yDir = 'down';' E0 m7 U( I3 f
var superballRunning = true;% x' H6 d8 g& g
var tempBallSpeed;
; b/ L2 I; C/ c% dvar currentBallSrc;
- }; s8 K' U. W f3 |var newXDir;9 i) Q) b+ }* C4 Q
var newYDir;
# F1 y; H# v2 S* i8 i: i; o' u% N/ D1 Q) Y; M/ w
function initializeBall() {
' b: r G+ @6 v- X if (document.all) {
4 V& z1 r$ Q7 N- y1 _ xMax = document.body.clientWidth8 \+ R2 d. P: J' u; z: `" C. f% z
yMax = document.body.clientHeight3 I% W7 s; B0 P2 s
document.all("supertext").style.visibility = "visible";
w; q1 P: O& q% h R7 S( K3 q' h contentWidth=supertext.offsetWidth t) T4 i# i5 k. x. v* o
contentHeight=supertext.offsetHeight+ d, A V% f+ c2 A: U
}
; M: r( e- S9 t( e else if (document.layers) {, e) `; |9 v& X' L
xMax = window.innerWidth;
O) @- g5 [1 {/ Y( n' c yMax = window.innerHeight;
7 j3 H, c: D2 r' p5 v6 f6 P contentWidth=document.supertext.document.width* D8 z! W' F% n: Q9 @
contentHeight=document.supertext.document.height) l7 f" g' X* w' E
document.layers["supertext"].visibility = "show";2 F% q$ C! x& T* [' o2 N. x) ]
}9 H% w2 I9 g' h
setTimeout('moveBall()',400);
1 |1 i6 s. X) i: Z; J+ h6 b5 j- F if (hidetimer!=''); ^- I3 v8 q: N) L. F- }
setTimeout("hidetext()",hidetimer)
- b: w: l) c; x; Y5 J. V' E$ ]8 J }, _" V% N/ s4 `3 }
; T1 l6 {, {& t! G/ |3 k2 m" I& P/ \function moveBall() {
. F4 }; q% T$ @4 m# v if (superballRunning == true) {
# r5 b# Z+ Z6 u0 V' h calculatePosition();
! p) H) Q8 ]/ t if (document.all) {4 x8 ^6 L' J: h$ n* p- ]0 J
document.all("supertext").style.left = xPos + document.body.scrollLeft;
! S4 ]& U n+ R2 `$ h, Y1 h( U9 S2 u document.all("supertext").style.top = yPos + document.body.scrollTop;
& y; O7 _2 ~" I; } }
; Q0 \0 g/ Z# d+ A1 d( n* o0 X1 K% ` else if (document.layers) {
, _' c* e& U: F& p4 W document.layers["supertext"].left = xPos + pageXOffset;5 D" V2 ~# p3 v% b* e: J
document.layers["supertext"].top = yPos + pageYOffset;
* {9 o' V9 H7 i( i& T l5 } }% V8 R% I$ _4 }0 |- |
animatetext=setTimeout('moveBall()',20);! M: L7 C) H3 [
}# d5 B5 t+ l, S" l
}
0 F5 O* g# m0 j: {0 ~
. o: T, {$ w4 V: Ufunction calculatePosition() {
' B2 G. z) O) C if (xDir == "right") {( T7 v( l; Q4 G2 h9 S
if (xPos > (xMax - contentWidth - BallSpeed)) {
) r, k O" {1 o5 n: m1 K. c xDir = "left";
) ^) h! |& J0 w }
8 k7 f( z" A% I/ s4 {' {! G# ? }
& Q' m, ~) A- t& t7 N8 g2 T9 k else if (xDir == "left") {3 u; M. ~& a1 r* U
if (xPos < (0 + BallSpeed)) {, N0 T8 A2 r% ?0 O) B6 O
xDir = "right";
/ Q! I/ n4 L. j U4 j0 O$ F }$ h7 x( v R& `2 l3 z7 z, Z k% Q( [
}
$ T0 l* `9 V Z0 ?9 g8 L- ? if (yDir == "down") {
' V) Z' ]7 s5 f$ d+ h5 m if (yPos > (yMax - contentHeight - BallSpeed)) {
4 ^8 T7 @4 V# q% f0 J yDir = "up";
( o2 d) ~ g! _2 j }
; [& l$ z% I" H# i5 k }
1 L7 @) E7 M7 Q* |) y else if (yDir == "up") {- U, B& m( P; F9 D7 c+ y* S
if (yPos < (0 + BallSpeed)) {
8 l9 S! g3 r; m* n yDir = "down";3 S# D9 E/ [0 q- g
}7 V5 [5 z. W5 u* o9 \9 A# i1 W. @
}) u9 L5 i) G+ {1 {$ i# x/ c
if (xDir == "right") {
' ?- i, a, J+ _' r9 }: Y4 N, a xPos = xPos + BallSpeed;# E; `/ V& v/ [% b0 N* f. w# j4 ~
}
7 e* z5 G+ d0 A! o. y, }5 U8 H else if (xDir == "left") {2 `6 g+ c6 S% U3 R4 s/ \
xPos = xPos - BallSpeed;$ h2 o* m, t3 z% t" s9 J
}
$ F' Z. a, W: e: S) | else {- s: K6 ^5 V4 r, f5 ^7 K8 {, v! f
xPos = xPos;1 b8 d t- a/ e8 Z- r! q# v3 ?
}; r8 [* M$ H( `6 p: Q' g2 O
if (yDir == "down") {) H2 C2 ?$ G `
yPos = yPos + BallSpeed;9 z% U6 G2 C: Z
}9 ]5 d5 c' C3 D! z( U. [# R2 X, J
else if (yDir == "up") {3 t+ {$ q5 G$ A9 {& j: j
yPos = yPos - BallSpeed;
9 f# p2 {1 R- x H }* d8 J3 U t7 G8 Z+ O
else {
3 w- l0 J( X; y. } yPos = yPos;0 Y9 Q( U1 H2 w* h
}
4 j0 M3 d" c, n% Q3 U! H }
/ N; P: B* a5 c$ ^ k2 W; e' A2 E
function hidetext(){& p8 S1 w! ?! X6 X. f% [9 V
if (document.all)
0 Z; ]0 E& A" B5 T( C. a8 @supertext.style.visibility="hidden"
8 p4 l O% z2 z2 {# |4 ]1 ^2 A( b) P4 Celse if (document.layers)5 B# ]5 a) [3 B8 \! e6 Z
document.supertext.visibility="hide"
# L. w# P: ^! G+ R" {% dclearTimeout(animatetext)
$ |% g3 U( G: y4 e' L}
8 M. b5 _2 `5 ~, ?2 j K% F. z$ }; b: u
if (document.all||document.layers){2 \( S' o0 e7 R( w/ ^: j3 Q
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
5 y0 j% Z) O5 q: z$ v) M7 owindow.onload = initializeBall;. g! Y& g- e) l- a l! L
window.onresize = new Function("window.location.reload()");
& }- x, s5 `1 Z; _0 k) o. p}
3 n* d0 G3 `8 {# @8 W1 D
% F& o: u- e \# S, V# A) Y# g/ T</script> |
|