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

|
网页之不断弹射的文字-特效
<style type="text/css">
! I: b5 G' E3 } i1 k) q% b* j5 j U#supertext {( @# s: g6 K) }% \7 J
position:absolute;( k" I5 A x" Q
left:0;
: @8 K1 O4 d) W7 N V+ t5 G; itop:0;1 g z$ i- k. i( T5 U, f
visibility:hide;2 \% q# r2 @1 i2 k6 n$ E
visibility:hidden;8 M- W" m7 n1 J* [# o' |
}
6 w1 b- x8 f" J</style>. o! C% g: p( i% v0 @. s
<script language="JavaScript1.2">
# C4 Q6 o3 V" d5 r& l<!-- 改变下的字体的大小。颜色-->7 g9 z) E! |" A- q; E0 o& f& {
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ H* |: ]" D8 C* \) P+ S5 G3 v
var hidetimer='';) z. L5 H! R6 i
<!-- 改变下的弹跳速度-->
5 ~! c. ?8 d4 D0 Q2 t+ Jvar BallSpeed = 20;
! h3 L3 i. ^$ R9 a! K/ ^var contentWidth;/ r0 }0 W& k9 S$ y3 }1 h- q
var contentHeight;
8 w( i3 Z+ R) Ivar maxBallSpeed = 50;
i7 j( r, B6 B
' O" j6 y1 G! c% `2 k& K. |
" }) O- Q" V% {+ T$ }' r* dvar xMax;9 _/ h% r/ _, f: b% o& d7 M
var yMax;" K! P9 e6 P4 T+ X$ @
var xPos = 0;1 e% ~( n2 q- C8 ?9 ~
var yPos = 0;
9 b- d* y% j. |& T$ Y' Rvar xDir = 'right';' [$ Y3 K! ~) K" C
var yDir = 'down';& K T! ~; ^9 G! X
var superballRunning = true;
# M+ U8 u; u/ {. j1 P5 s- H" V1 [8 mvar tempBallSpeed;
% f. E0 A2 g8 l6 t0 b5 c# n3 xvar currentBallSrc;
4 o* t, K! y0 u& {% j% w# O9 Gvar newXDir;
: \$ P. c! }* f4 |; Svar newYDir;
& b2 O8 F( v7 U Q3 f6 j% B1 V1 q1 b* g7 J
function initializeBall() {
- c4 T6 i C" B: w, { if (document.all) {3 |5 A+ l% r/ K7 w& Y
xMax = document.body.clientWidth
# n7 [$ ^7 ]- X r# P S& @ yMax = document.body.clientHeight: r' p, L7 P* B* p, |7 u; m
document.all("supertext").style.visibility = "visible";/ R* c7 M; t2 b4 V
contentWidth=supertext.offsetWidth
, ~( d' q# n! F- n) U5 Y contentHeight=supertext.offsetHeight
3 p* I4 \* F' j# Y; I9 r6 u }
2 j8 U: t. C1 I/ F9 m+ C else if (document.layers) {
4 ]( f, N7 D' p' F P7 y xMax = window.innerWidth;
2 {' q8 \. ?1 ?3 }8 g `: c5 o: ?" w yMax = window.innerHeight;1 s7 v# Q7 p+ s0 k* {( ~+ V
contentWidth=document.supertext.document.width
: @. `2 y: T7 h/ S; P contentHeight=document.supertext.document.height2 W7 c: @! L6 W$ H" _
document.layers["supertext"].visibility = "show";
6 S+ }7 ~: g8 L' x b. p; I1 t; y9 c* I }$ M+ p) ?( U: F
setTimeout('moveBall()',400);
7 d; T" t& }) ~! z I if (hidetimer!='')
$ X4 L; i. p$ d/ A k setTimeout("hidetext()",hidetimer)( i, r9 U$ o4 `3 B& x7 a: F! t
}
+ s; O' M" g* T+ t0 l* r, a+ N/ ]8 @- `
function moveBall() {0 u: b1 b. X, U# e2 K
if (superballRunning == true) {) ^" t1 S* q- W5 e; p
calculatePosition();1 ?; O3 ~) y4 p" f1 S
if (document.all) {
8 o9 {. c) y$ H document.all("supertext").style.left = xPos + document.body.scrollLeft;! p1 q5 X ]7 J' {) m
document.all("supertext").style.top = yPos + document.body.scrollTop;1 P% [" u( c6 e( _8 I6 }8 z
}/ h$ m$ Q. f! _) R
else if (document.layers) {
. P) G# _# }( G* r6 D. d document.layers["supertext"].left = xPos + pageXOffset;1 @# f8 M/ ?" g" u! V' ?, h
document.layers["supertext"].top = yPos + pageYOffset;
3 r$ L7 m. x3 o! A" P }4 M. x1 g) N' m& Y" p2 t
animatetext=setTimeout('moveBall()',20);
; A @5 \4 D# I/ L% H }4 ] U; @0 ], w* F+ V/ h
}
5 U. f9 `4 u& ?( @2 J" |& D- J. s3 V! ?- G4 X) x7 G7 {
function calculatePosition() {, S% r" b: ?$ i+ }! F. _
if (xDir == "right") {, Q3 i% p W8 r; K. A @
if (xPos > (xMax - contentWidth - BallSpeed)) {
0 G8 D" K0 t: |9 [4 M U, f xDir = "left";, @& k5 C( J, o2 X/ ]1 R
}
( j9 d% u7 ^% {6 e8 I% P }$ a* W- ]$ r! n* C! p* e: M' _2 g
else if (xDir == "left") {
! v% v, z6 }$ I7 b: d if (xPos < (0 + BallSpeed)) {
+ Y% [+ A7 J: x3 ` xDir = "right";/ j) l% s( V9 O1 n( i
}! _/ s( j7 b# _% j* f1 U1 C
}0 p5 v7 y7 J2 b( a9 a# e( V, }
if (yDir == "down") {; Q* E' L' v4 Y) q
if (yPos > (yMax - contentHeight - BallSpeed)) {- u% B; l- s7 R$ E5 X. R6 p- v
yDir = "up";
$ T2 p- E) F/ o+ N }$ ]9 P8 X8 u# w* `: u* e9 j
}
6 s3 q1 m# f& ]' g+ Z else if (yDir == "up") { J$ Y" W: K x$ v2 Z
if (yPos < (0 + BallSpeed)) {
& V. v) D/ O2 i2 q yDir = "down";1 z6 a+ v" M _- c
}0 S- ^% R+ t- Z
}
2 I; V2 |1 s m7 _/ g6 e& E1 _ if (xDir == "right") {
$ [+ u8 [, N" B, z& W* b xPos = xPos + BallSpeed;
' I0 X3 W c! }7 q4 u" M }* r" B1 J; r7 v# }
else if (xDir == "left") {
" n A9 ]. j* t- b xPos = xPos - BallSpeed;+ I# U" z0 g: [# a4 }% n6 D
}
! Y3 E6 D; H4 B6 D1 ^ else {1 @" O: D/ d* C8 a
xPos = xPos;9 k- c8 U1 d& @( K' H0 X3 l5 G' X
}
, A: N6 A" P+ }: f$ h/ N if (yDir == "down") {
; J* O( H7 a) c5 q1 v yPos = yPos + BallSpeed;0 R e, w( s) D) B; r4 n* {- M
}
Q! c+ U4 N8 T& S( @8 H else if (yDir == "up") {# k6 G3 f' J0 q( Q
yPos = yPos - BallSpeed;3 z$ M2 i8 y6 j4 {
}- _5 q8 {. U4 d4 b Y
else {
% Y) t- U& q7 ^5 P- d1 l& G yPos = yPos;) u9 O( N7 H/ o0 {! h
}
$ Q; R- u$ c& s( a }" r5 Z: \$ }- L
3 R1 ?6 ~; ^) n4 u/ X
function hidetext(){
2 u0 O: C K4 R/ Pif (document.all)* F5 |8 K" j2 r; g2 F5 u
supertext.style.visibility="hidden"
1 _' A H- L6 c; d3 P0 ~else if (document.layers)
& W, @5 r- l1 L: I- q- [document.supertext.visibility="hide"' b1 @9 Z: I S% `) f, I- Y
clearTimeout(animatetext)5 l5 E) l6 }" u% h g0 D
}
: S( T3 ?( I8 r# Y l
" D0 o& [5 T- y9 c j9 fif (document.all||document.layers){
: ^5 J, @" c2 ]$ ldocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
( K0 }$ x; d) c: }) awindow.onload = initializeBall;
2 }# [5 H/ t% c, a' u/ ~window.onresize = new Function("window.location.reload()");8 k% Y' y9 Q5 Q# R+ g# s0 ~
}- e# o( o% Y$ F0 C
1 M+ d( k. L' _- Z& o, r
</script> |
|