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

|
网页之不断弹射的文字-特效
<style type="text/css">
; Q! d# k4 @; g2 q" l( U9 e5 u7 v( w9 R ^#supertext {
0 D0 L) Z% h0 x# l- v* J. iposition:absolute;
1 M" G. S# I: U( @% Uleft:0;
6 z! ^8 c R# K; ?* J6 i' ntop:0;
0 }0 S0 a: Q6 y6 V. |+ Cvisibility:hide;& }0 z! A( m4 h# V0 V2 m
visibility:hidden;4 ~# W( r1 n) D# _7 z- d
}
& D" K! A1 ?9 R$ E, g& c9 i- T</style>6 c* D/ z, h3 U% U
<script language="JavaScript1.2">
! W( W8 u q) B8 h4 |" \& V<!-- 改变下的字体的大小。颜色-->
, R; ~; a# d- G& evar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# M* d. g9 u6 b
var hidetimer='';
. v" H3 [; @0 X3 p4 b<!-- 改变下的弹跳速度-->
5 W/ L3 R1 h: g# f9 t0 k" w7 Q& xvar BallSpeed = 20;
! v9 K: f+ N3 b# w4 N3 }. Qvar contentWidth;
7 t4 X( ~0 f; n+ M# F+ }var contentHeight;7 g- [4 j/ A) S3 E. f( ^ ~' h% d# z
var maxBallSpeed = 50;0 f% m8 L: F& ^1 u: k5 Y
3 T) N& R: M" Y) u/ u" q7 l4 a( |' `" Y; ]. C* e( H3 [# A
var xMax;3 o- v" A5 [1 Z$ p% n
var yMax;
5 I" n; y7 a3 C; w. A- b- kvar xPos = 0;
2 }% E+ j6 S9 z' [: \5 Mvar yPos = 0;. z$ V# O2 E) f" x( x
var xDir = 'right';9 |$ v2 D3 i& c6 ~+ l' M
var yDir = 'down';
; b [! {( N* m ]$ V8 xvar superballRunning = true;
0 A M+ {, q2 F7 y, r. U c: S, v) P6 Hvar tempBallSpeed;
1 S* b! x2 R0 A# f8 P) Avar currentBallSrc;
# D) d) z. L7 X2 q! n Yvar newXDir;
7 ]4 }3 w( N& B1 d, `& y7 n" K! J. Xvar newYDir;
: ^( ]0 H' D8 r1 Y
- Q8 ^) G- ^4 [( u0 L7 [- Yfunction initializeBall() {6 R5 g6 a! Y% c @$ e
if (document.all) {2 i) F/ |, E, p8 R, `8 F! Q: \
xMax = document.body.clientWidth' n2 s/ W9 M' B. ?/ L5 u3 p# f
yMax = document.body.clientHeight8 o7 J% j) u1 i. U& J1 ^
document.all("supertext").style.visibility = "visible";
& d, j& [' C! V1 F contentWidth=supertext.offsetWidth
2 @/ ^6 M/ d1 Q0 X& }( n. f contentHeight=supertext.offsetHeight
9 k G( \* W/ ]. [ }+ [& y. h6 f' D2 ~
else if (document.layers) {; Z, i, y1 R$ }
xMax = window.innerWidth;
2 L/ n/ A/ q4 o1 M; d8 N yMax = window.innerHeight;
% {6 O* T% l0 P0 h contentWidth=document.supertext.document.width3 ?+ s) x ]) K6 H; r
contentHeight=document.supertext.document.height
2 k# _5 o' {4 V X0 M8 \. V document.layers["supertext"].visibility = "show";
& M0 |" _# ^5 v6 p( M }6 _/ q' X# t9 N) P/ Z; S. P9 t
setTimeout('moveBall()',400);
! {. k4 D- u# z0 j if (hidetimer!='')
% ^7 ~9 n2 s# I) [% a1 ^$ y- N' K setTimeout("hidetext()",hidetimer)
5 ^: S* q% f# h' A }, P3 S: ~& `& A6 b& S( {
4 H: d) f6 ?3 i* A6 s* Yfunction moveBall() {0 z" ?8 T1 H- o4 L1 J
if (superballRunning == true) {4 {8 u( t u; a. `* x$ A1 M7 g
calculatePosition(); {# y4 G5 P! l
if (document.all) {
2 {, m/ c- {/ u" F0 X& d; U document.all("supertext").style.left = xPos + document.body.scrollLeft;
. ~$ ^, A9 g( I v5 x% d2 k document.all("supertext").style.top = yPos + document.body.scrollTop;9 s4 V7 ?" L: Q p8 M; r
}6 g- Z2 g6 a5 _' O
else if (document.layers) {5 G# N c( C6 i8 |5 i0 h
document.layers["supertext"].left = xPos + pageXOffset;$ m% _% w7 J' b! z# B! f0 }
document.layers["supertext"].top = yPos + pageYOffset;
' J& B* ^+ N5 u& e) a" {2 T0 l$ E" Q }% ]: w" b( S& z \7 y* e* p
animatetext=setTimeout('moveBall()',20);) m8 u. t9 j2 f/ E7 a: [ W
}' {- {$ Z8 T! g2 }8 k& Y
}
, I$ M: C% z+ w- ^0 z% P t
, S6 q0 g! G5 c, A1 t- `function calculatePosition() {1 h8 }% i: w! ]- h6 R& D
if (xDir == "right") {
4 p- k/ H3 E+ q/ V: O" |! [2 e6 t+ j if (xPos > (xMax - contentWidth - BallSpeed)) {
5 R+ C7 G. Y9 ]. P xDir = "left";4 L# l! p$ [0 h; @
}. Q2 K V6 n& \) v! h8 N
}8 q5 |7 \* z5 `: `& Z
else if (xDir == "left") {
p: m' {+ F/ B7 k7 K# @ if (xPos < (0 + BallSpeed)) {
6 Q$ f9 `% f1 o xDir = "right";/ Z& g7 t2 N& V7 T5 [
}2 `9 `( a, n0 l' l: G: L: i
}
7 d) K# P9 O! ^- Z- K if (yDir == "down") {1 |% [1 e( ~4 F# f& O
if (yPos > (yMax - contentHeight - BallSpeed)) {& B8 ?- {- B7 H9 U
yDir = "up";
. e1 `4 }: S/ {+ [1 k }
0 Q2 N6 j. X$ |0 T/ c. i9 R! j9 e }1 @+ z/ k" E5 R! H2 @4 H! x2 {
else if (yDir == "up") {9 q3 N% M4 K) R1 [, x9 v
if (yPos < (0 + BallSpeed)) {- _3 L; c# b% f# t. V
yDir = "down";
) S. ]* z1 b5 `% ]- z0 w4 K }
' E B: ^" W* ?! \7 G9 v }+ L& V4 P; b m( R
if (xDir == "right") {& ]9 g. n& e& ~/ }1 h9 g3 `
xPos = xPos + BallSpeed;6 h$ E- E+ C( Q, t
}
2 c1 @( s9 y9 c* m: U- N else if (xDir == "left") {0 u- I! d) d1 r* G7 @5 V5 W
xPos = xPos - BallSpeed;+ m, f; f5 N6 C5 k5 S
}
! W6 `2 y8 g% N# p, E else {! m$ S- ^" e- E
xPos = xPos;
3 [5 ~7 f V8 z* G( W% ` }
! q' F' v2 O9 W' j* L* O0 r if (yDir == "down") {& D; f9 J- w2 e& m4 ]5 z6 ^
yPos = yPos + BallSpeed;# `* t0 G# F4 B( Y4 I) `- S1 C$ a
}0 O( M" e# l5 W0 S) {$ y% U. F1 H
else if (yDir == "up") {
) H+ c) {% B {4 |9 C7 | yPos = yPos - BallSpeed;0 I& q0 {! T" M0 `' j
}
) a0 z# j& e: g% e4 K; Z/ U else {5 r0 l4 x/ M+ B
yPos = yPos;, j* P) R- ]- V
}
& c) V0 h7 u7 w2 D8 x }
0 o6 r: G. x. i: y! i4 P3 \. X/ G4 V/ M' s0 B% e7 U- \$ j" d% I
function hidetext(){6 u, @$ G6 m9 p$ V! Z' L2 T
if (document.all)) C: `5 O8 s' I% Z0 J# w* s
supertext.style.visibility="hidden"0 a$ _$ i7 s% O+ p6 g1 C
else if (document.layers)
) A& x0 |0 P8 o- a, f4 _document.supertext.visibility="hide"
w7 {7 ?- L" O P& N2 A' k2 V8 E& ?clearTimeout(animatetext)& [; V6 i2 e8 M
}7 h; o8 t0 y' ]' J- `
- m$ U2 q" d: c& U, w$ N/ B& Eif (document.all||document.layers){* ^: @2 a4 o7 Z* A+ j5 {
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')0 M" I+ Q6 _( a* |( j: H( T
window.onload = initializeBall;% x% h+ B8 T9 J3 J6 h
window.onresize = new Function("window.location.reload()"); K$ }. x$ d: ^7 p: }
}
9 S# }. E& o- U- A% ~. W& {$ ]# ~2 B) u" ~
</script> |
|