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

|
网页之不断弹射的文字-特效
<style type="text/css">$ Y' t V" Q! d9 l/ e" [( A
#supertext {+ V3 V1 O( G# X0 h, y4 n8 F2 w
position:absolute;3 V' s# l( c u/ x, J
left:0;% ]$ x5 ~1 ?# o+ K1 S. A
top:0;' A7 n+ A& w$ [
visibility:hide;
, |+ a! S& \9 Uvisibility:hidden;
) T6 D' y4 m- n6 M/ t9 R}
' Z4 h6 [5 K& V9 p; D</style>, V) |; e7 U( }9 Q) ~) w" e
<script language="JavaScript1.2">
2 d" b+ V# E M6 t: \1 n<!-- 改变下的字体的大小。颜色--> a; q* C0 i: D% u/ i, S
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'( p9 f9 F) ~8 }$ S
var hidetimer='';0 x7 D* t% _' d8 C' o i# ]
<!-- 改变下的弹跳速度--> ? ?5 U3 D8 M2 z
var BallSpeed = 20;' j% Z5 H' v/ N R, H+ |: ^; A: k
var contentWidth;" q) o6 ?" Z2 N" }6 r/ z. A
var contentHeight;1 j* \7 C! G9 M7 W3 j7 B/ M
var maxBallSpeed = 50;9 @! f {/ k1 z8 S9 q/ ]+ B
% A' R' B6 O6 X6 o$ @+ m9 h: m
2 b2 Q; X- w4 Q1 x" i# {
var xMax;- X j! G1 A, X) ^- l8 n
var yMax;
) B- C2 W" C+ k4 j$ Ovar xPos = 0;) Q& l8 [7 R* V% M
var yPos = 0;% y, H Y8 l; C( s* A; m+ P
var xDir = 'right';
6 Y" E( G2 U& H" H6 {var yDir = 'down';( V# i/ V3 x5 c* H9 T) g
var superballRunning = true;
. F3 v5 Q, }4 ?9 yvar tempBallSpeed;
' d: S; N* n# J; _9 \% Hvar currentBallSrc;& B' f0 A4 C9 f" B3 o e
var newXDir;, w* ]+ m( Y: A" q
var newYDir;
. c A! w9 Z% v- L
2 }8 O5 [; m. Z6 l5 \ tfunction initializeBall() {3 M4 j4 I5 Y* [- `- v
if (document.all) {
' w) R+ N5 W: \2 u xMax = document.body.clientWidth- l5 q- S- d( @/ q0 n
yMax = document.body.clientHeight9 z4 Q: {/ w* H; Z" \
document.all("supertext").style.visibility = "visible";
) @7 R6 z4 t6 ] contentWidth=supertext.offsetWidth5 V$ [) ^- A/ o6 Q+ [* {9 `
contentHeight=supertext.offsetHeight; t7 u7 c, E8 q1 X, {+ B) q
}$ |8 X! _: k1 i4 W, E
else if (document.layers) {3 |" [$ k% x8 p5 ~# }
xMax = window.innerWidth;0 I7 y$ \& t. O4 E9 H* k
yMax = window.innerHeight;& J% E& Y2 V: g& r" n6 c: c
contentWidth=document.supertext.document.width
7 a) D: `, `" b contentHeight=document.supertext.document.height! z9 i# t/ s* h. g
document.layers["supertext"].visibility = "show";$ a& u/ d; q* @- _
}
J4 ~5 L+ n4 K% z* P9 @5 L setTimeout('moveBall()',400);% c' h, K" V" v$ h
if (hidetimer!='')) Y" q! Q9 N7 K7 t f
setTimeout("hidetext()",hidetimer)
" f& f& U: m4 Z' v- ?" {1 | }! W! H; L% R$ s V8 g* L2 b- \
# Z" M1 {9 ?$ ]+ Sfunction moveBall() {' ]8 |+ }/ V; X/ A
if (superballRunning == true) {
9 G4 b* \2 G* t" P3 r- n- b1 N) ? calculatePosition();
- b4 B/ p" a5 h o if (document.all) {
( d* E( {* e# x4 u1 e document.all("supertext").style.left = xPos + document.body.scrollLeft;
5 U, @& Q" k6 Z/ V document.all("supertext").style.top = yPos + document.body.scrollTop;
, Q$ G& D; |; y: t0 k }) l" _/ k" E( _7 |; i% g, j/ L
else if (document.layers) {/ z: i4 T1 K( M `1 ^
document.layers["supertext"].left = xPos + pageXOffset;9 Z. N/ s# O3 @ l9 w
document.layers["supertext"].top = yPos + pageYOffset;, t2 @ k. ?* Q, y. m# @1 ]
}
0 t! k# R- S. ^% b animatetext=setTimeout('moveBall()',20);4 z) d3 M' `; h2 p: E
}; R3 t$ a, a& W% Z% ^6 F2 o
}
& ?7 P# x k& I
5 J/ c; c$ l0 J1 }function calculatePosition() {
+ F% f- b0 I0 }0 T0 V( L if (xDir == "right") {
" x6 N; s% X5 U1 L- V! ^& q if (xPos > (xMax - contentWidth - BallSpeed)) {
( r6 H) r5 u+ j0 V" G4 h0 G+ C xDir = "left";
( U3 x. ^/ {8 y+ Y+ A1 {( \ }& ]. }. @ t5 R; w* H" z
}
& a% m- k, Y5 z S0 N else if (xDir == "left") {
5 l" D5 l# K% I0 l& [ if (xPos < (0 + BallSpeed)) {% I. ?" ]5 n- T7 ~
xDir = "right";) e3 F" w3 `0 U6 A
}
Z b6 l5 V1 z2 t1 D; Z& Q( \4 I }% E6 N- N/ T, H4 t# j+ F! d. Q
if (yDir == "down") {; [( {$ v. t% C; n& x( h" R( s8 ?
if (yPos > (yMax - contentHeight - BallSpeed)) {2 e+ D: Y* a1 r# e8 ~
yDir = "up";
' m: ^' o) _* L }
' Z. ^& X, V6 y& w# m' l5 A }* z5 E5 g2 @# L& L' f
else if (yDir == "up") {
6 X- M+ E; M4 E. | ` if (yPos < (0 + BallSpeed)) {7 U' t- w% F1 k4 l) G9 m
yDir = "down";
* ^5 }" n' }2 R }
- C1 X# J% P* S }
4 ~$ l9 x3 K) y" M& o. i if (xDir == "right") {' z1 F* L# i/ W9 r& `
xPos = xPos + BallSpeed;
1 M; Z8 H. x8 t4 Z" v/ v }
( l. T9 c- g/ I( f5 @ else if (xDir == "left") {( L ~7 ^( c- M: }" y; N$ a" D
xPos = xPos - BallSpeed;6 B+ ~9 y# J7 I' d: m
}
3 K6 o- [/ T: h! M9 O! r( j else {
! C* A8 w/ e1 X- \, N/ y. o! A xPos = xPos;0 Q* H" u% \2 h
}
% y0 [! m9 o7 x' a0 G6 V* g( e if (yDir == "down") {
& P2 R, h; o6 [ u' ^' I! b yPos = yPos + BallSpeed;
' U; R# X$ q7 Z) Z1 @5 J. ^ }0 ~5 V5 k/ o5 c; i+ C. l8 U* K+ j
else if (yDir == "up") {) L( h" W% y7 Y+ t4 M
yPos = yPos - BallSpeed;
8 C! `) J/ \. ?# f z/ ~5 ^1 [ }
# _0 y, v- ?4 K+ e e else {
2 W/ P( A. O9 g$ W6 O$ _: X yPos = yPos;1 w/ ^' [9 {0 @' v" d/ s0 }9 t" l" H) r
}2 [+ M: t% `8 I+ O# p2 N/ ^
}
9 e# Q3 p6 e8 O; }
8 [& G; H/ ^9 X+ mfunction hidetext(){0 k I% j: m% I0 E; Z' ~ o' L0 [, a
if (document.all)7 J& a; n Z0 o
supertext.style.visibility="hidden"
; W& B' z r; \/ {5 |0 n. y2 lelse if (document.layers)) x: B$ g4 }3 A* V$ R/ Q
document.supertext.visibility="hide"
2 W9 H$ u4 w% I3 T% ~+ E xclearTimeout(animatetext)
1 ] M8 N" R! X+ \1 }) x9 k. d& H/ t, g}6 @$ j7 A1 T, J& t& b' @6 ]
1 ^, O2 i( c3 ]3 B R2 m. h' pif (document.all||document.layers){
9 A6 I9 v# V) w1 `document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" X+ i4 f) O6 I* `% `* |3 L7 W! |" Twindow.onload = initializeBall;; d9 w8 j5 `6 B5 T8 T; x% |
window.onresize = new Function("window.location.reload()");
# e+ v8 f* }- ?# X/ m% n/ P8 x# W}, K" z! U$ l3 Q4 }. `
. v' e+ M+ H, Y</script> |
|