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

|
网页之不断弹射的文字-特效
<style type="text/css">1 ?7 D' _# w: ~% P6 S. ^+ m
#supertext {
0 _* K" c! U. K7 z1 Q' hposition:absolute;
. p0 Y Y8 `% Tleft:0;
0 {! f, g2 y* r' \top:0;
) @8 Q8 U4 R, ~0 H Mvisibility:hide;% D& `% e& [ i1 `# z
visibility:hidden;
4 J0 j" A5 o0 o% A$ ^& S}) }" O" f; k8 V7 w, p
</style>
. r5 }" k( M( }, B/ a0 c' E/ i<script language="JavaScript1.2">
2 I4 H8 l# c3 [% Q" ]<!-- 改变下的字体的大小。颜色-->
, N, W0 H+ T, M1 B1 T | j! V6 }var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ t) c5 L. f3 a+ G4 U" h& s* a
var hidetimer='';
: T/ M: d7 B& a' n7 ^<!-- 改变下的弹跳速度-->
[' g# A- W. `6 s; K- v/ j8 |var BallSpeed = 20;
I: O8 u1 \1 G6 z' uvar contentWidth;6 n/ }$ A" q! F, g! u/ }3 [
var contentHeight;8 F' e$ D6 H! b
var maxBallSpeed = 50;- r5 q5 w) A' ^% N
/ H' ^ y# @$ f' }$ l0 A! [! B
+ g4 L- r5 ~% a1 }
var xMax;
4 Q F+ y) `: C0 n+ b- Svar yMax;
8 ?/ U5 O' U# u8 A0 u* \& t: hvar xPos = 0;$ C6 Y5 y: A, R: _- D% F9 O7 t7 B
var yPos = 0;, i7 u4 N% m6 p% w! f8 A
var xDir = 'right';! {/ E/ I9 l$ G, B# M* l
var yDir = 'down';
3 k$ i0 V8 K2 zvar superballRunning = true;
8 x* B# V- V: u) \8 Bvar tempBallSpeed;2 ~' I! z2 C* f! B. |
var currentBallSrc;/ o7 S$ d; \3 R
var newXDir;
; |4 K. ^* t* tvar newYDir;! W3 }( d& Y) q4 |. q
3 c# S4 ^- t2 m4 U! _' o; M
function initializeBall() {" K7 ^- d: p2 ~/ @
if (document.all) {; G' O: D% L! ^/ j: E
xMax = document.body.clientWidth7 T- L5 x. i$ I. v( w7 U
yMax = document.body.clientHeight
8 s; z3 o4 t* Q document.all("supertext").style.visibility = "visible";
/ O+ C; p. G; w% w5 i. O, P# n contentWidth=supertext.offsetWidth- y$ u L: n$ t* ^" i
contentHeight=supertext.offsetHeight
0 w* e, b. J2 T* x }
) X3 _8 Y9 P9 s2 M3 U else if (document.layers) {* b: j1 }# Z& ~7 \9 ]$ p% _
xMax = window.innerWidth;1 N/ `' l4 H1 K
yMax = window.innerHeight;
. G0 _8 Y$ Z+ l- _: ~+ j1 ] contentWidth=document.supertext.document.width" t7 ]! [/ B- U
contentHeight=document.supertext.document.height) d: o" W9 J2 E# z
document.layers["supertext"].visibility = "show";
L% j' d5 I: g2 u0 m1 O9 b3 w }
# S" |0 X0 L x1 h2 Q; b3 j setTimeout('moveBall()',400);
, d* w0 O* J' v& I9 ?% } if (hidetimer!='')' i% J4 W! U* a( P; H2 }
setTimeout("hidetext()",hidetimer)4 K, @9 Q) H B" Q5 h
}
; j5 V, r2 |8 v7 l9 h5 k- a
7 ^( ^; J& B6 a7 E8 Zfunction moveBall() {7 T9 d; Z! Z! t8 ^& R* `% I
if (superballRunning == true) {# x# x! ^% M- Y
calculatePosition();: j* z, I: }$ j% U9 k3 m
if (document.all) {" u1 B2 ^( A: `' N( Y$ w
document.all("supertext").style.left = xPos + document.body.scrollLeft;
- o) {. A: J2 C" p, n( f, N document.all("supertext").style.top = yPos + document.body.scrollTop;6 [$ |% M% J" o' K! [
}
5 ^5 M0 E' v+ U% e- X& T$ Z else if (document.layers) {9 G v8 t) ?2 [" M+ I3 G, b
document.layers["supertext"].left = xPos + pageXOffset;! M# X, G' y4 W2 S' j% ?# Z9 f
document.layers["supertext"].top = yPos + pageYOffset;, T g! Y% Y! g/ X- w) X1 e
}; `. A& ^1 p1 C$ S. u' t
animatetext=setTimeout('moveBall()',20);
* [0 [7 {4 a% t& \" g; ` }0 ~* ^ O% n. \* P7 s
}
$ y+ t; P g# m6 Y
5 _5 x' A3 ]* g9 qfunction calculatePosition() {
( X' c1 J) D* U z if (xDir == "right") {. C+ o" T( Z9 A( i
if (xPos > (xMax - contentWidth - BallSpeed)) {; G0 m- c6 |" A# U0 |# ^3 C# ^( c
xDir = "left";, o6 `, Y4 J9 l
}
% l1 S9 N! U' ?! u* P; {6 y }
9 O% ` g: r* a x, l* F else if (xDir == "left") {/ {. a! ] p# U; \& D- e: ~
if (xPos < (0 + BallSpeed)) {
5 u& c, B! T5 ^- a6 X0 { xDir = "right";
% N- D# b; A8 h ~* Y }
4 C6 V/ W2 g" {$ j }% X) h" f9 \- j: u; T
if (yDir == "down") {
1 j! P1 g2 [* ]/ k6 L' a1 Y2 Q if (yPos > (yMax - contentHeight - BallSpeed)) {6 ]: O, z# w m- J4 `: W G1 m
yDir = "up";* x" t; N4 b( t
}
, w: X% Y+ ^4 }0 r }+ q, t% P M4 _/ [ y% A1 r) }6 g
else if (yDir == "up") {9 E% z9 I# j0 m# m+ o
if (yPos < (0 + BallSpeed)) {
& _/ N0 _/ O, x3 A$ b+ M yDir = "down";( ^$ [3 ?7 M, s: S7 F# D5 P
}# X; G* H% ^- L, u
}& y/ u, Z7 O! T9 Y( u& K) Y: y
if (xDir == "right") {
0 l U+ J3 S2 w* D$ B xPos = xPos + BallSpeed;
0 b0 f" Y3 m- c- B7 h }' }& a7 b" z, K$ c8 z+ }
else if (xDir == "left") {
( r/ m' _4 V$ C1 w xPos = xPos - BallSpeed;2 P' q$ c- Y+ m
}
- u+ b/ @/ ~" V% c" Y0 u else {9 d7 [6 u" X) f% p G0 M
xPos = xPos;
6 Q9 t* @9 I+ i, Y# T `) x V }
0 O7 D! _# ?: f2 G& p if (yDir == "down") {7 c0 n* P* h! ^2 ]8 |: K
yPos = yPos + BallSpeed;
, a2 d$ T% I+ G' ]+ w& q }
2 f. [6 x) O3 @, O8 c5 x: U5 ?, T1 [& Y else if (yDir == "up") {
: ?+ R2 ~! g, |! C yPos = yPos - BallSpeed;% w+ J* G) M" \) t/ W* Z$ `
}
; v( U' w) s7 y( L else {
" k' `3 C& t1 z$ R yPos = yPos;
2 i2 [% _) a9 p7 d$ C" v6 R; F }, r Y/ O; k" k& r+ T. q- b
}: I: H0 M, |4 P4 ]# O. Y& R
# }& @& u+ b9 v- R( F) Q& R5 I9 j) M
function hidetext(){' W3 m* O" {5 m. |: j% J0 K( i4 x
if (document.all)% E4 u3 v4 }: g( B* n
supertext.style.visibility="hidden"1 R6 o7 i" ^! `
else if (document.layers)- E. ^" f7 N( c# t6 V/ y( b$ ?3 m4 V
document.supertext.visibility="hide"
: e) z! c8 P' V) \clearTimeout(animatetext)5 U# r: x* q, _* D- G6 w
}
* V6 x, W$ Z9 L$ t Q7 y/ F' ~3 ?# f. i3 h e
if (document.all||document.layers){
5 c) O0 w- D! `( g1 Adocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 C/ r5 `# H& K3 R7 Wwindow.onload = initializeBall;
, s" f) s7 r* K! E4 \/ R: Rwindow.onresize = new Function("window.location.reload()");
7 o- h! @+ A+ \}
6 t1 n( u1 A" J$ T' M, t: J `. O7 r( `) r8 J" N4 C; _ z" A
</script> |
|