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

|
网页之不断弹射的文字-特效
<style type="text/css">, q8 W o0 j0 e# P5 q
#supertext {
6 a2 \! j) w# vposition:absolute;. W) y6 h8 S3 h1 w! M
left:0;, f; f# e7 l' v9 ?# T
top:0;& P$ W, G. ^" G7 z& n# ~& S' q
visibility:hide;1 I/ G% d, y! o1 O1 p' j
visibility:hidden;
, k# r4 H2 d4 s3 V2 _}& d# r7 }2 F5 Y2 [, @( a
</style>( u* _# m6 T& u$ B
<script language="JavaScript1.2">
' K8 @( l1 x+ l" X<!-- 改变下的字体的大小。颜色-->1 O& n$ @. c/ o- J6 a' ]
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
) j3 A) `: D3 C8 x4 }* Kvar hidetimer='';2 v# m* @) c. p5 Q6 ^: X; Z5 X% n# z
<!-- 改变下的弹跳速度-->
* |( h& ` J2 w1 B' Qvar BallSpeed = 20;( R% I/ _% F* c% s$ P5 F) z$ Q9 z2 g
var contentWidth;
! u* o" b+ A8 d2 mvar contentHeight;# ?8 s. e" L7 y
var maxBallSpeed = 50;
* G* A, L0 ~* e7 V G2 @
) C8 R; m8 |& X" q$ l
: x( k5 k* Q% F4 kvar xMax;* ^7 L2 k @2 W% h/ g; I
var yMax;2 o* [. f& R( F# h! L7 w: A
var xPos = 0;# l! y" k. u! e$ Z! c9 v& b2 j8 V
var yPos = 0;
7 X# d2 G1 ~: s& @( F. Q ^5 Gvar xDir = 'right';- c J) ~; ~2 l9 W% k
var yDir = 'down';
8 _6 V. o! Q! k: \5 V% hvar superballRunning = true;
* j$ X2 R6 I* N# Yvar tempBallSpeed;# M( s2 Y3 b% `9 @* p
var currentBallSrc; d5 a8 K9 j" n; R6 P* z$ A
var newXDir;
/ b- W! s. E+ s& d7 k. p- F5 y( Fvar newYDir;
$ J( N+ C; v/ w# l7 t( h
& u9 [; n$ l' O6 T kfunction initializeBall() {
* H- b; m; V! G! g+ g if (document.all) {0 Y6 |( W9 h# R+ G2 |
xMax = document.body.clientWidth& O: E5 Z3 ]/ h; F" @* y
yMax = document.body.clientHeight% k9 T8 `. V0 z8 b$ t5 T6 r
document.all("supertext").style.visibility = "visible";
3 K) j' w3 k* l8 d( N contentWidth=supertext.offsetWidth G5 m2 A) D6 r3 a% \7 {
contentHeight=supertext.offsetHeight* t2 u3 [. T+ B$ A
}4 ?8 s. w- x, g+ V/ P/ u2 r2 V
else if (document.layers) {! J8 \) ?" u& X! Y& S5 u i
xMax = window.innerWidth;8 y* C1 |% t$ a6 d
yMax = window.innerHeight;
+ C" }2 |- r& F( J" W8 S( D contentWidth=document.supertext.document.width
: a H- ]3 a! {2 y5 R) \3 P contentHeight=document.supertext.document.height
: B$ _ C! R1 K# s document.layers["supertext"].visibility = "show";
5 `* @1 q, ^. U8 G& ?8 R M }
: h2 g$ \' t' m) ^. Y setTimeout('moveBall()',400);
1 d H$ T+ S# q if (hidetimer!=''): P- E: `# k7 G! A- o; ?8 W* L
setTimeout("hidetext()",hidetimer)
, @. @# ]3 T; y5 I }* h- i: E; A) y; l9 R$ ~: \
5 P) q( }4 g. b; N$ ?function moveBall() {
8 G$ N# C) ~( w$ }+ T if (superballRunning == true) {: e: R5 M8 I9 u- P4 x F
calculatePosition();
9 r( ~ o5 s- ^8 b9 ] if (document.all) {
8 k: _- ~, i1 X% n4 h2 B- S document.all("supertext").style.left = xPos + document.body.scrollLeft;: e$ Z: c4 E5 D5 E
document.all("supertext").style.top = yPos + document.body.scrollTop;% M" [! A% z4 k7 l" _5 H2 A' k* |
}3 s4 m! S8 r: @+ K, g
else if (document.layers) {! O( \9 w2 @. a) [9 `
document.layers["supertext"].left = xPos + pageXOffset;+ P0 H" b3 j, z$ O" G; C2 A
document.layers["supertext"].top = yPos + pageYOffset;5 [$ Y% R5 f8 D6 P8 Q+ G
}
1 E) y6 w/ f: v1 U! |$ z animatetext=setTimeout('moveBall()',20);
L$ P/ k5 y& e/ u" i# h }
f! C8 L9 I, I! i }
2 G" X4 }8 D$ h' s3 ^& x" \% a- G# n; u8 s( N& _0 Q
function calculatePosition() {
; X- K% @. l3 F8 U. B) N) H if (xDir == "right") {6 L; d- ~" J" d/ V
if (xPos > (xMax - contentWidth - BallSpeed)) {
; x4 q: _( p( N' J8 M xDir = "left";% b1 d% O4 j0 }+ V6 N
}" S# `% }& j! g" s
}' _' o- o, W* H
else if (xDir == "left") {
4 \& A; a: U* d4 e) @) D+ r4 ?' P if (xPos < (0 + BallSpeed)) {
r9 u, l; r( N9 Y* o xDir = "right";2 Q/ E: P" e- I; u
}) f& d& }' ^5 u; P% [4 ^
} w) W: ?7 `: Y7 r9 R: {8 D, S1 F
if (yDir == "down") {) {5 M4 w5 w" j5 p
if (yPos > (yMax - contentHeight - BallSpeed)) {
- \/ \" C k8 G! H8 ^' H* B yDir = "up";& C% D6 }8 b$ ~, W5 s
}: R1 O& {6 X, I* _' B9 V
}
; Q$ Y8 T' Q x! `1 q" i else if (yDir == "up") {
4 U/ a/ j! @% ?# \5 Q$ O if (yPos < (0 + BallSpeed)) {
3 g4 q+ r( X' j5 ? yDir = "down";
& |: A2 l1 O) h& N" k' O* m; k }. n K( r4 \2 j& X- o
}
0 o" d2 \' W3 {9 W if (xDir == "right") {
& U; [. r+ }1 F xPos = xPos + BallSpeed;2 i% W% ]* b2 f. k: Y
}
" G7 t6 Y2 t6 } P& U else if (xDir == "left") {5 A! I4 R1 F$ y- P) c0 e7 I
xPos = xPos - BallSpeed;
s: X8 W, g, ^+ [4 a }1 }( Q' x$ N3 j! @
else {
( r$ @0 @% O9 f7 C) I- [( R! v- { xPos = xPos;
- f5 | f, D K. L; l1 C9 k }6 j- u! G2 O+ U
if (yDir == "down") {
1 l8 @# x, B9 V" F. r yPos = yPos + BallSpeed;
7 M) W% z1 {; b# r }
$ x7 _0 Y& J# v+ `2 O% _2 L2 b else if (yDir == "up") {. c% d* L t2 r( }. i
yPos = yPos - BallSpeed;8 e2 |6 H" N$ [) ^/ q J9 E4 X" U
}9 ?; x% Y0 c3 U' t( ]. i" v% I# S
else {3 z, t5 d/ ^' c/ V2 Z$ [
yPos = yPos;
2 t8 p) q3 l7 @) X+ b }5 S/ L! U, h1 ^. Z
}
% u; h# ^* b m
9 j2 ~$ k3 B. z% V* O) Q nfunction hidetext(){7 c/ [. x- [# @7 u. c, r `
if (document.all)
4 S3 m7 a- O; Xsupertext.style.visibility="hidden". W7 ^: b3 n+ z, h
else if (document.layers)
3 f) u6 u3 T, u3 `; }4 w8 idocument.supertext.visibility="hide"+ m1 z* r; K* M9 r
clearTimeout(animatetext)
/ |! o: i! f7 g" ]& q, S}
6 p, ], W# y3 t2 F: e( j+ }5 P+ L
: b/ K B$ V2 l8 D! M' Jif (document.all||document.layers){; |/ b- n- S1 m9 o
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')8 _1 l' S, T# i( j4 L3 ?- T
window.onload = initializeBall;& G6 P1 i+ f7 {7 V3 D) g+ d
window.onresize = new Function("window.location.reload()");7 H- S; s/ P8 I- m& Y. V! D/ W
}
* ]% s2 P( Q# h) }
5 L# H) d( Q6 \" Q</script> |
|