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

|
网页之不断弹射的文字-特效
<style type="text/css">
u7 ~$ W2 E& D& m$ G, X4 C#supertext {
/ c5 q1 D3 z# _9 i( r/ w9 p, uposition:absolute;4 L, h0 o1 p* } p; V
left:0;' r( _6 T$ L0 J$ u3 r/ [
top:0;. K# s" _& A& L
visibility:hide;# d( c' N- s$ k9 ^+ W) r, U5 b5 n
visibility:hidden;" M6 i! |" H1 y
}; l, P( j$ O" R5 n
</style>) O# p% M5 N' L+ e3 G2 H2 V
<script language="JavaScript1.2">
. d5 Q2 R) p& a* k3 P& f" K<!-- 改变下的字体的大小。颜色-->
: a. M0 w+ m; T) O- C0 Y: m: q. r. X: nvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'3 n7 \) r8 v; T9 O, b
var hidetimer='';
( A2 i9 T) b4 g/ o8 F- m<!-- 改变下的弹跳速度-->5 q' W! J1 R3 F7 K. j! o" R
var BallSpeed = 20;
4 [: G' [6 O' evar contentWidth;- o) A3 [' V b, |! P
var contentHeight;6 v8 y7 x: l1 n4 q3 H
var maxBallSpeed = 50;
+ C9 V: g# s. H% ?; C0 [- ^8 h+ V4 l: E% R
- \8 J. ?7 f& \* {$ `) I) K% i2 _& V% S
var xMax;
. S* v+ e3 e' i) ^/ M; kvar yMax;
9 h5 l; Q# d# Y: x2 X* j8 S- |var xPos = 0;
' @' H% A. Q$ w. Lvar yPos = 0;
5 ~9 ]( A& R& B8 a) b8 Tvar xDir = 'right';6 Y& `2 A" x& K# {' D, \! O- e- C
var yDir = 'down';
1 Q0 ~2 M1 M' O7 tvar superballRunning = true;* p) W d; l5 s9 {
var tempBallSpeed;
0 _! O0 T3 |, B: j! O$ cvar currentBallSrc;+ c% S$ e' k$ \' O3 u! O/ c
var newXDir;
: w; h& f6 s) b& zvar newYDir;- X/ Z$ j6 R. G' e7 ~0 [, d
* F# L! j- S- Q; Q
function initializeBall() {
. N. [% m, l' ]2 y if (document.all) {/ w7 m0 H7 r! ~- N+ x, q8 S/ b
xMax = document.body.clientWidth
2 Z9 h' S6 q' _+ s$ J, H; t! ]: e yMax = document.body.clientHeight+ `0 u. D: z: M! b1 _9 ~& e+ ?2 G
document.all("supertext").style.visibility = "visible";9 q- W! i$ e9 q3 S* D2 ^ r
contentWidth=supertext.offsetWidth
$ V3 H: U* `( E. m9 ] contentHeight=supertext.offsetHeight0 b. P6 X0 h8 {# L- J. N" c
}* t/ k y# {" @$ Y5 g1 Y i
else if (document.layers) {8 U! @. F& S8 Q a7 H0 h
xMax = window.innerWidth;
7 b/ ]1 F2 y$ f( S" F2 M. t yMax = window.innerHeight;
1 J8 O* U# l1 j+ s0 ~$ Y contentWidth=document.supertext.document.width
8 b& I8 }4 j3 f contentHeight=document.supertext.document.height% I7 V1 Y, F9 f- j6 ^
document.layers["supertext"].visibility = "show";
4 |/ ~1 ?# n+ v2 `; y! V5 I, G }, T o0 d% u' J4 u: \
setTimeout('moveBall()',400);. _; d7 B+ m" ~& I" J4 s: V, q( n
if (hidetimer!='')
' Q, s9 v. o( y' A setTimeout("hidetext()",hidetimer)$ m) @* M. ?- m. A
}& k6 x L/ ` L) H
- h) `/ c# `4 H; ofunction moveBall() {
4 L) O# c8 ^* q) _# b5 }3 \ ~ if (superballRunning == true) {4 u& S5 M1 s$ `! M" ~
calculatePosition();
4 I" S$ B: L4 J9 ^8 T3 |& j if (document.all) {# g$ W& H0 R0 `
document.all("supertext").style.left = xPos + document.body.scrollLeft;
# b7 q* K1 f! P) |% i7 e: m document.all("supertext").style.top = yPos + document.body.scrollTop;8 d9 m' h$ M1 H
}1 W& P. l$ W* I/ V
else if (document.layers) {
, _; {$ } ?- p! o document.layers["supertext"].left = xPos + pageXOffset;7 H) u! }( K2 L% t, r
document.layers["supertext"].top = yPos + pageYOffset;
1 P6 o$ u/ o( N5 q) X' l }
) M+ T, R* O% l4 \. I! q: f animatetext=setTimeout('moveBall()',20);0 d1 G; _/ r6 C+ F0 l- y" h8 [
}; m$ U" L) Q$ O# u
}# n3 s' E( a. b6 u* ~3 V8 @" X' }
/ ^& G' }- r0 Z' L- n' E
function calculatePosition() {: P5 _; H5 c& g0 I4 P" z- v
if (xDir == "right") {
# ~3 [, o/ J2 r P0 |8 H/ q if (xPos > (xMax - contentWidth - BallSpeed)) {; Z0 q) L8 {* Y7 e0 T) k- z
xDir = "left";6 z& f5 O+ X2 @% l/ ?) R
}
% |! j% B5 z( P: h3 h5 | }
! U/ W. Q% d7 K# j& ` else if (xDir == "left") {1 j5 j2 A" f @! |
if (xPos < (0 + BallSpeed)) {
) C! Y- k% ? u- ]" `5 B" e; S6 J xDir = "right";
, x0 D; t w4 l7 C# A. L }
7 l6 S/ O; e! w# K8 z0 P, ~ }1 t% K2 h8 M% ? {( Q
if (yDir == "down") {
0 R+ u6 A# i- o6 W1 u: ~4 a if (yPos > (yMax - contentHeight - BallSpeed)) {
* G: X& f; u$ k- q% A' o3 k" J yDir = "up";
. f& E2 [& M) F" Y, y5 N }5 Q/ `) |9 C3 h c" r
}
: p/ S6 F1 E: r4 m7 ^- ^ else if (yDir == "up") {% P1 T7 z& d" ], O& [$ B
if (yPos < (0 + BallSpeed)) {
O1 `3 r; I O/ E# L! `# | yDir = "down";5 S# @2 J: H# }5 ]; A
}1 G& ?' z" ^; c
}
7 n& l7 d% o: M7 i+ s% Z if (xDir == "right") {) K6 f m: K$ ?6 t& ~) \
xPos = xPos + BallSpeed;
" M# f, ~' z. F/ \0 q9 P7 x/ }% r }0 s: y, I+ [3 V5 u2 i( T$ n
else if (xDir == "left") {) ^& V9 \8 M5 n0 a7 \
xPos = xPos - BallSpeed;' F' x9 [8 G! t$ q
}% }, \/ B6 B7 X' T0 E
else {- b0 \& L$ } f8 W
xPos = xPos;
- X |5 g" M" M0 X }) e K- r* U7 p4 u
if (yDir == "down") {
, S# S1 j# U! j# d yPos = yPos + BallSpeed;* w' _) w0 |& k) F4 f! G4 ~
}
i1 U! f& ?3 m( n else if (yDir == "up") {8 m# k# Z- j: i0 n4 S
yPos = yPos - BallSpeed;& M. d5 g5 ?' E | ]0 \
}
5 I+ N& ?. M) |1 V. f3 C( G! R7 v else {4 F* u/ H$ H/ }1 g0 q/ A
yPos = yPos;, z0 O5 [4 B0 `- D
}
2 N! o1 r' w7 o- P }
; y" `- ^# {- W& G: ^% w3 k5 Q9 M3 T% ~9 ^
function hidetext(){9 r% J) K- A' G8 Z
if (document.all)9 r; W$ n& c0 r/ x
supertext.style.visibility="hidden"" m! I0 B8 |) |1 r5 g
else if (document.layers)
; K* Z8 w; a) N( i4 ndocument.supertext.visibility="hide"# H5 [& }6 I6 _+ }2 O" Y
clearTimeout(animatetext)0 e+ J' ?: j' A6 H/ i4 q
}" d3 ~4 i* T3 h" ]
5 M3 a9 G0 m. z# c& o$ h% m% ]
if (document.all||document.layers){$ K w: }/ }/ R5 m
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')! {6 b) _+ j( c! ], V
window.onload = initializeBall;
1 i) m- c. D# H# {& l3 wwindow.onresize = new Function("window.location.reload()");
. s* n9 K# E0 ]* Q}
0 k) X' `! n6 o0 J1 K J: e$ L$ s! r, O1 T6 ]
</script> |
|