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

|
网页之不断弹射的文字-特效
<style type="text/css">' V! W, X# {& N) u) n* s. W0 D) U
#supertext {3 j7 x; J! n) D, e. n
position:absolute;0 t8 D: i: g" ?, q
left:0;! }0 E7 I) A; T- M' m) X, E: f
top:0;5 A% q k, v$ m$ {
visibility:hide;
9 F( ~, N4 h! @2 Cvisibility:hidden;# w; y/ }# k) }7 r
}
* E$ D! K: ~ z3 s3 y5 [$ F7 X, Y0 P</style>
6 u3 R2 H4 d* A" k<script language="JavaScript1.2">8 |$ i& h( y: J9 U( H* ~, m+ y; ]' |
<!-- 改变下的字体的大小。颜色-->
+ P" [6 \# d4 ?/ kvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
! w: r% u8 g( s* nvar hidetimer='';1 Q3 J9 J j8 X- k' P
<!-- 改变下的弹跳速度-->
/ F2 a5 H" k& |6 Svar BallSpeed = 20;
+ b+ d8 m* m% u3 P$ Dvar contentWidth;
, I) p, Q, c) A+ h# ?var contentHeight;2 v" B5 Y5 ]3 c! B6 `
var maxBallSpeed = 50;/ W0 P2 h. `" V9 W; I
9 C3 X) `( p, G, S- B" M" t$ n, i2 ~! B" c5 I
var xMax;+ I4 Q3 I+ y+ \- I8 |
var yMax;
3 ?' n$ W: \$ P6 B0 O5 ]; Lvar xPos = 0;1 i" k4 k5 }! L! c0 f0 N! Y+ {
var yPos = 0;
; A1 Z5 }; h! [, b! wvar xDir = 'right';
/ N- X* D& ]+ d, g+ m6 k" Tvar yDir = 'down';
# S- m# b, I0 E: I# Evar superballRunning = true;' @$ K) i+ l" B
var tempBallSpeed;6 I! M- `3 z, O% ]7 O0 P
var currentBallSrc;: }0 }2 _. h# E5 \3 I% D
var newXDir;
7 M. f% t- f4 [* |; Ovar newYDir;0 _; V+ b a; Z' b5 T" O
) g6 o3 j& e9 P1 O0 X1 ifunction initializeBall() {
5 \( M( Z c% K! u: ~; h if (document.all) {1 c, w: B% t5 k# S" x
xMax = document.body.clientWidth
9 }. S3 _+ @6 L" D) s9 J yMax = document.body.clientHeight' A* P3 i) c8 W; d: G- @
document.all("supertext").style.visibility = "visible";
5 N: k/ N* p4 R- y& ` contentWidth=supertext.offsetWidth8 _( p& F1 k& q( a! T, }
contentHeight=supertext.offsetHeight$ G0 m- \5 B: O
}
) L1 l! B( }2 p4 D; _4 W! }1 v4 A else if (document.layers) {$ I/ l0 {" a3 `7 _7 n. W
xMax = window.innerWidth;
2 X* w" q/ b4 B' y yMax = window.innerHeight;- k% A4 ]. F0 T) V9 ^+ M/ d2 u
contentWidth=document.supertext.document.width6 o( @- y% e" G0 d Y0 T
contentHeight=document.supertext.document.height
, ~- H- z! q! D document.layers["supertext"].visibility = "show";
/ F5 G9 m" H( s: b4 c }
* C5 x( P) Q! K0 r! C' R setTimeout('moveBall()',400);
/ S/ j9 @0 S% D5 g: s& Q2 p if (hidetimer!='')
7 |. N+ q- Y. X! G setTimeout("hidetext()",hidetimer)& }! j6 w$ K% T* _' l4 |
}8 v0 J) X3 j5 V9 h
- |. X5 e, C3 O+ i
function moveBall() {
* T. G9 f8 N( M5 n3 z% Z if (superballRunning == true) {
% t- ?% i3 u. Q; G1 e calculatePosition();
" u5 }/ t( H. h0 n$ ? if (document.all) {6 N2 u/ \' P" Y/ P/ o% Z F/ N6 M
document.all("supertext").style.left = xPos + document.body.scrollLeft;
! A& K& f& ~6 A0 x" Q; W document.all("supertext").style.top = yPos + document.body.scrollTop;
' @7 z; `% Q6 w, ~0 o$ D9 X }) F5 B' T( M g. y0 \3 |- j1 k2 x+ |
else if (document.layers) {* E& K8 |! V) y6 F
document.layers["supertext"].left = xPos + pageXOffset;, L# n+ X! ]' C. ]! E# l; v) u& d
document.layers["supertext"].top = yPos + pageYOffset;
0 i/ u- _' C) n }
9 Z3 E/ K, ?* i- K' ^ animatetext=setTimeout('moveBall()',20);, P, @; p* y7 r2 W" T
}
% w* e$ q: Z. ]5 x' U3 b' X" o7 I6 \ }
9 Y2 K2 A% j; ]6 s; C
2 T( z0 V& w9 P5 d9 l' tfunction calculatePosition() {" f$ _6 H' l4 o3 J: m/ U% u8 _9 e o
if (xDir == "right") {
. z1 T* o2 X2 c. X4 L( Y+ w6 N if (xPos > (xMax - contentWidth - BallSpeed)) {3 s5 ]; e9 i' K0 K% g5 p2 W8 Z+ k
xDir = "left";% Z- r4 g* |2 e2 r
}
% r2 P1 ~: [9 K* a6 [# J( _0 M }7 p( l2 O+ R5 [' i& x
else if (xDir == "left") {! R6 k- q* i; r% s% \" B
if (xPos < (0 + BallSpeed)) {
P3 S) E( g7 s4 b4 M xDir = "right";
( p; B" S" g+ u) K+ d }6 \! p9 K5 w9 l
}
( z; W7 \/ j' c" c if (yDir == "down") {
7 }; s' @$ } r* s2 Z if (yPos > (yMax - contentHeight - BallSpeed)) {
8 W% r% @9 U' t6 A& }6 n# h yDir = "up";9 K; W; R. E9 A2 q. c" X
}
! N" V+ w. i- T+ G/ A }
& h! z" H6 a5 P6 a4 r else if (yDir == "up") {' y/ H0 @6 s3 B6 n: Q
if (yPos < (0 + BallSpeed)) {
) F: k' G* W+ {5 E- u8 C, V yDir = "down";
' u) \) }( n/ r }/ J; `" t8 u7 m' z- O( a6 D2 {2 O
}
5 q1 \5 O% K9 T6 t% I* Z( V( n if (xDir == "right") {: b0 U% H! v- i
xPos = xPos + BallSpeed; m7 @+ G7 h0 e, n# X3 ~7 J
}
' }1 f4 z; S+ N8 a% E/ X7 H0 y else if (xDir == "left") {; ? G# b* H$ ~
xPos = xPos - BallSpeed;
$ c: _3 a( ?4 o }# S: _8 _ P' ^! N
else {6 c# G, B1 S/ Y: r
xPos = xPos;" c) a6 J: D' L8 C2 A! ]9 t
}
$ b) A- W+ U( f if (yDir == "down") {
3 u+ b! g6 R9 t- H% E yPos = yPos + BallSpeed;
: a |3 [: m1 F! r }4 X2 g i4 M' N7 I, T% I
else if (yDir == "up") {
3 ^ {5 _5 y4 `7 O- i6 | yPos = yPos - BallSpeed;
4 ~! I0 i& X7 Z, {3 \' u }
# E) W5 P5 \9 X else {
+ r1 g* a- }1 _$ u4 ] \( x1 S yPos = yPos;2 b2 B6 U4 S8 P! S! \* M
}
( l- T) ?9 V, d+ U }- z( T7 H/ B+ A
/ \( e& Z" _: s) q% \7 B: l
function hidetext(){
+ a1 R; i! f* P- F1 C/ zif (document.all)
, }5 e& F: {! r( O& Fsupertext.style.visibility="hidden" ^* `' I3 Z, O/ V
else if (document.layers)
" N" f2 R% n! m$ i. hdocument.supertext.visibility="hide"
3 Z, K) [( ]1 z' w& n: a% ]) GclearTimeout(animatetext)
0 N4 c# N7 b7 E9 h4 q5 i}8 z) ?4 j- m6 \; `
9 j% u0 M; P9 ^6 H r" Y9 t1 Y: Eif (document.all||document.layers){
8 u$ M6 Z/ Q3 L+ G3 u* n. ndocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')4 P" u5 }8 i, b( w; f n* `7 i3 U
window.onload = initializeBall;3 H% D6 T$ Y% O
window.onresize = new Function("window.location.reload()");
' K( y) q+ f% g}
3 p- a- K; Z) M) W
1 f0 V! j; h/ o2 E2 b</script> |
|