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

|
网页之不断弹射的文字-特效
<style type="text/css">9 Y6 l( L! m+ ^5 a
#supertext {+ m& A$ z( K) U7 q4 @
position:absolute;
/ Z* E2 L c6 I- Hleft:0;
: i3 E: g& z, y' d& w: stop:0;
9 @( H8 l7 |4 O" yvisibility:hide;
. U2 W+ ~% g6 _4 Z" kvisibility:hidden;2 r- V2 p* A) h9 ]7 q3 j3 G1 o$ ?6 w
}7 v% Q9 G' k. D1 X: F
</style>
; T/ A9 ] U% s9 S4 [<script language="JavaScript1.2">
- s$ u I- N6 t! \( Z6 M t# T' q<!-- 改变下的字体的大小。颜色-->
/ H3 w- |$ j7 g4 E' B! M$ v* Z- j7 Qvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'3 V* t' U+ l# w; l. F1 B
var hidetimer='';0 U+ X- ~3 l; F/ ]1 Y
<!-- 改变下的弹跳速度-->
: E9 y, Z( ]3 U9 svar BallSpeed = 20;
/ D+ v0 b* W$ h8 Nvar contentWidth;/ T( _8 H& i$ z- ~
var contentHeight;
/ z% L5 v/ c8 Q8 A: v7 svar maxBallSpeed = 50;
- h% b( H% U$ B' Z, f2 y( W: ` y% y
! J/ G9 I( o% h0 O: k$ `6 Xvar xMax;' I1 W+ E3 y8 _8 J# d
var yMax;& V6 F+ d2 v( ~4 b! M
var xPos = 0;) t) j, }- J6 a+ P& S4 |
var yPos = 0;
9 h% ^: G" b" ^$ B: M6 }var xDir = 'right';
5 o' t* }0 c, R7 vvar yDir = 'down';
: r% Y* G& V7 A5 L& a" Q' x! }var superballRunning = true;
; f$ v0 ~' h: v( v5 t/ H4 Ovar tempBallSpeed;
5 P, v1 S! l6 \* y0 E% P( Ovar currentBallSrc;
# ]2 v& R& e: |3 y3 r( \* Rvar newXDir;
9 o; S- M: C ^. Avar newYDir;
4 n/ g/ h5 i7 `" R" M5 E) w6 l" z+ |+ K* _2 J, b8 v$ t( p( I! [" T
function initializeBall() {
$ k+ ` E' R- Y if (document.all) {, G3 }) Z0 W2 K0 Q% E5 n
xMax = document.body.clientWidth
+ f; V/ K1 T9 C) P# |5 X8 ] yMax = document.body.clientHeight
6 I# ]& r1 a; _. Z6 L/ D' u* B document.all("supertext").style.visibility = "visible";/ ^$ C3 q* D N# z! U# x
contentWidth=supertext.offsetWidth
; n& S( I/ k; B# O5 { contentHeight=supertext.offsetHeight
0 @/ @! k) {& w' B }. b) t( ^6 {3 y j0 K
else if (document.layers) {
+ [# {! | }. d+ g# F# _( _4 U xMax = window.innerWidth;
/ S! I4 o4 v0 G5 d' ]& H0 Y, C yMax = window.innerHeight;
% Z# i, G5 K E( q, ^) b& d contentWidth=document.supertext.document.width3 A% I, H0 ]4 @+ t- l
contentHeight=document.supertext.document.height5 z2 t/ x$ \$ y. c5 O2 d; F
document.layers["supertext"].visibility = "show";8 j" c8 t* a* I& W4 g: i6 r6 V
}: B7 T Q9 k) J2 `
setTimeout('moveBall()',400);# j. N4 T$ W( ?+ T
if (hidetimer!='')
! T$ O5 L9 o& D+ k- z& F setTimeout("hidetext()",hidetimer)
: r% K. `& Z2 g7 o6 O }2 ?7 }) ~: m- K5 H( w D" L
$ b3 E& a ?8 ofunction moveBall() {
# q @# m K% e( c6 y+ d' Y if (superballRunning == true) {
" _ T/ \% S0 u' }& h+ B calculatePosition();' C4 m. v% y& N1 ~) V0 g
if (document.all) {$ i0 y* b1 k3 g7 g+ |- ~
document.all("supertext").style.left = xPos + document.body.scrollLeft;
3 G9 h" j7 A, [4 c8 R document.all("supertext").style.top = yPos + document.body.scrollTop;
( g/ O+ b6 V% U& R$ ]- C( g }
0 a0 m, I, `( X" T else if (document.layers) {; c/ ^$ t, L' P3 s3 i
document.layers["supertext"].left = xPos + pageXOffset;
" {# U& s- D+ [ document.layers["supertext"].top = yPos + pageYOffset;% y; A' |1 Q) s2 O
}' v5 R# e$ ?6 }; A. L! }# u! P0 N
animatetext=setTimeout('moveBall()',20);! U) R" n: w a* W) ^3 ` e
}
& o' D3 ]; T( F }* {) K' I C5 f, z6 M# q- P5 a: t
; L, |* V! w$ P, q+ h5 t8 Mfunction calculatePosition() {
5 D4 @% S9 G1 u+ P! {. y if (xDir == "right") {5 R' {* c6 Y0 ^# F/ S9 {' D0 R" b
if (xPos > (xMax - contentWidth - BallSpeed)) {1 [! h) W6 R5 i6 g" [
xDir = "left";8 X2 P* M" d2 S5 m0 ?7 Z( ^" G0 z
}4 W4 B* V" `8 q) `; I
}
/ F4 Y3 h' b5 f" X& O; k else if (xDir == "left") { X6 u" i1 p3 S2 x! r
if (xPos < (0 + BallSpeed)) { C9 g7 ^% {/ M8 V" x3 [) M
xDir = "right";" q( y/ a: e5 C. V! ]
}
& O$ b: o* T- U }
; ^( H, p! V& E1 I if (yDir == "down") {
& n+ C& Y5 f$ I- `7 V/ b if (yPos > (yMax - contentHeight - BallSpeed)) {
( h/ s$ o" @0 }9 n" i1 h$ O* ~ yDir = "up";
3 S3 ?7 B3 ]; H }
/ X1 K3 ^6 U3 Y }( s+ N0 Y; e2 l5 M5 j; f5 S
else if (yDir == "up") {. T: R R" p0 Q* n! K/ l' o4 I
if (yPos < (0 + BallSpeed)) {, K' }$ p+ ^" k! m$ L7 j- x
yDir = "down";
0 ~0 `, ?- {, y* q" r4 R# @ }
* F+ h# ]( J" Q7 {4 ?; R }
+ G0 c% `: X+ f" x6 B- D3 t# G if (xDir == "right") {, Q$ K# K. |" r: ~0 a7 ~1 d* G
xPos = xPos + BallSpeed;% t% N3 B: }6 m }
}
# L2 T& P. Z4 `4 e9 C5 O \ else if (xDir == "left") {
3 M9 C* l( r+ G: l xPos = xPos - BallSpeed;
8 j$ }$ i4 j/ J3 o1 B! ?0 N }
1 d) r: \7 x9 e3 Y9 v9 U else {
7 a# a4 i. r+ ]+ B1 ]5 s8 e4 {' _ xPos = xPos;
9 K& q# ?6 X+ j+ n- |9 z }
, b% C/ F$ t d% w if (yDir == "down") {
) a. w9 n: B/ Y$ V9 t. v$ r yPos = yPos + BallSpeed;- K( Q" L& u$ q( P I1 f
}3 g v! c$ e8 o: ?' a+ N; y
else if (yDir == "up") {$ {3 J$ G9 w) \6 ?* O
yPos = yPos - BallSpeed;
6 W+ L k/ T( c. C% [ }* H) h8 B& S. C f# F1 }5 k9 Y0 p8 ^
else {
, @; X% D$ }, R: ~' ]9 q) W& a yPos = yPos;
; F9 L/ m! O6 h3 T$ E+ ? }. @* k4 l5 R0 d% x
}2 a: ]0 v2 W* {
" g5 O3 A% {! B; Z3 \# J- u
function hidetext(){5 t+ D2 H9 V+ @( g* D; M' y5 X
if (document.all)
V+ }, X' p; r/ Q+ M k3 t- |supertext.style.visibility="hidden"
+ R9 o+ e( H: b* z1 c0 H- Zelse if (document.layers)
6 D4 r- c( m, mdocument.supertext.visibility="hide"6 G+ j Y( E9 s
clearTimeout(animatetext)
1 ]9 A3 c* P2 Z8 R. u. Y}
+ V/ N7 W' K% y! _; n' w' J6 X" @6 t3 f4 u" T1 ]
if (document.all||document.layers){
4 T, {8 {! A# B& Wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
4 \1 ]$ S. ^, p0 X$ }window.onload = initializeBall;8 ?8 E1 A& Q0 r; u5 ?7 _. U+ E+ Z8 @
window.onresize = new Function("window.location.reload()");
8 s' j/ p# \$ d \}* }4 w& [1 v9 [; s
) f' N3 O9 x; {: g1 f
</script> |
|