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

|
网页之不断弹射的文字-特效
<style type="text/css">' W# G5 T. H% [- E) `/ l
#supertext {
9 @+ o% b+ o. `, G" o. Aposition:absolute;
5 l x, {0 J4 K( `! U( }$ \" Xleft:0;
+ [! E n T+ u3 itop:0;8 h1 c$ P6 D: O- S
visibility:hide;+ v, d0 W+ Q$ P4 s; z% v* r
visibility:hidden;: s4 b, e9 p+ e2 f8 I
}8 G1 E7 }* F; V
</style>0 u; W' k7 d. w5 T4 j [' T
<script language="JavaScript1.2">
: A: [* O4 h6 F# k$ e<!-- 改变下的字体的大小。颜色-->
, w; v$ v) U8 G t+ {var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'& H7 y9 z, w2 T+ O5 D* A
var hidetimer='';
7 S7 ?5 Q0 A3 c3 D' {<!-- 改变下的弹跳速度-->
1 M+ U9 E8 O4 Bvar BallSpeed = 20;: m: D' y8 W( y& s1 X! H
var contentWidth;8 m' u* V8 S* o6 H( ^9 g
var contentHeight;
. o3 ~/ s/ Q! j0 xvar maxBallSpeed = 50;! B4 O( X0 [3 N. V
; n. E9 ~; D1 W9 l$ M6 E
+ J! ^% E; G0 T& qvar xMax;
) [) T7 a4 u! b8 U0 F: ovar yMax;
; s! m% g% @# }: e! t5 Z5 `/ P) Gvar xPos = 0;& ?& }5 e+ N9 Y/ u( i
var yPos = 0;0 [* X' Y& P v. g
var xDir = 'right';) o: e$ a1 b+ y- Z* X
var yDir = 'down';
, C+ U; X9 h6 J* evar superballRunning = true;
: y8 R& d4 \$ b) n1 G+ Rvar tempBallSpeed;
5 q! J \5 D B0 U. \3 l3 Qvar currentBallSrc;
; Z% ^) T$ r T: @; a1 c* uvar newXDir;# \, C# Q1 Y' v" S# N+ x! E
var newYDir;$ s: \ j* S E4 H! T2 I
/ ~( L; ~3 @" G
function initializeBall() {! S5 [5 N5 e% p; Y/ |
if (document.all) {% N/ k0 \6 G) Q. F' Z' w
xMax = document.body.clientWidth
" p4 a9 K& V" T' u yMax = document.body.clientHeight
. T: s' s9 A8 \3 h' Q* B- W document.all("supertext").style.visibility = "visible";) c/ b5 {5 {: A0 S: f `
contentWidth=supertext.offsetWidth
$ l+ h1 i0 e) {) D# y6 ~1 w contentHeight=supertext.offsetHeight# M' A% t! @! x- u* L
}( N* @0 `! o+ m; W
else if (document.layers) {; A! `: _; M: v0 m) f# T; z# M$ h
xMax = window.innerWidth;
* X- e% n. ~9 V yMax = window.innerHeight;
1 |+ d! {1 [: U contentWidth=document.supertext.document.width
p& n' P K- N T) A. A contentHeight=document.supertext.document.height
9 r' Q) w8 t, c9 u0 B. ? document.layers["supertext"].visibility = "show";3 L& Y/ H4 P/ ^ W5 V
}
1 J! t$ ?+ o) Q1 i0 \9 ^1 V, h setTimeout('moveBall()',400);
. b/ v: U7 T. q/ Q if (hidetimer!='')* a9 c+ e+ Z* o: ]
setTimeout("hidetext()",hidetimer)1 m* |2 a& o' I
}
/ m8 S8 u$ c! c! X6 P
; r) l1 u& m: p; ^7 ?) [2 Xfunction moveBall() {% d2 p+ g4 E2 ~- S
if (superballRunning == true) {/ j" ]1 V8 m, w$ c7 R" p( \, ]1 E
calculatePosition();
1 ?' m6 C$ b2 f3 A% T- C if (document.all) {
% v7 G' p Y7 p I, N1 T: T" ?! y! A document.all("supertext").style.left = xPos + document.body.scrollLeft;
3 F- D( x4 z2 J' e5 F1 ` document.all("supertext").style.top = yPos + document.body.scrollTop;/ s' Z- n. D* X7 N0 H% N2 }
}# z: G( G% Y9 \$ p
else if (document.layers) {7 z* ^. G( v. g1 X& Z+ `6 ?7 C* C
document.layers["supertext"].left = xPos + pageXOffset;6 F7 L6 L- H1 [+ Y/ G; t+ n
document.layers["supertext"].top = yPos + pageYOffset;6 X: ^9 j2 W/ S$ P2 h
}% I$ R8 H# O4 [
animatetext=setTimeout('moveBall()',20);9 g# H% V7 v$ w$ _; a& l
}1 Q( Z( y+ H' ?" D* z# \0 J f$ i2 z
}
& y B5 a$ o2 V( r! t0 c, a" J5 k" @6 C3 T( I
function calculatePosition() {& [0 {( E( ?0 g, S; K0 H+ E
if (xDir == "right") {. f. {) ^5 E& O3 H6 B2 G
if (xPos > (xMax - contentWidth - BallSpeed)) {: l$ _6 b K0 N, y" w8 s
xDir = "left";- k' l) J7 D# y$ F: |7 k
}$ u% A! C4 S+ I/ w# G
}
( p* ]8 B/ p+ A& y5 s else if (xDir == "left") {1 p* G# C5 |# u7 L. G3 H
if (xPos < (0 + BallSpeed)) {
$ c' s9 g- A. w* T. R6 u xDir = "right";
# d' t2 }" s, Y+ q& G7 M }/ L5 e& |8 R: Y3 y
}
8 Z1 z; e+ t; P1 _( } if (yDir == "down") {
' i1 ?) C, S6 ^5 K) P if (yPos > (yMax - contentHeight - BallSpeed)) {; t+ i( b4 V- ^; Z/ n: ^
yDir = "up"; E( b6 r* T& S) m t9 _ H, x
}
1 u& E/ ], a9 X9 [7 y# ^ }
h9 k, R2 U' W else if (yDir == "up") {
; W# V6 ^' S( ^) y if (yPos < (0 + BallSpeed)) {
) x2 H! |' s, {- E- c( b: j yDir = "down";1 N$ J F9 U7 q: d8 ]
}& Q2 k: X* t* ~/ D- Y' p& q2 B
}
3 ^5 ~" `1 D3 D" x if (xDir == "right") {
3 O: h2 f2 ]2 B xPos = xPos + BallSpeed;2 z4 ]+ u2 D3 G r1 C" m
}
1 z/ D3 A( m+ K" }* y: E, J else if (xDir == "left") {
0 S, l6 R# K/ A" L xPos = xPos - BallSpeed;4 K+ ^0 o" e; u0 f6 g
}6 B, t. \" E1 K* b( I5 G0 j
else {
: i9 G1 f. J1 d+ [1 v xPos = xPos;) g! o3 v- v1 a3 [
}6 w4 a8 w5 l; u2 g7 q2 c' s% Q3 z
if (yDir == "down") {, h7 `6 Y& y0 B/ q- z \& [' [
yPos = yPos + BallSpeed;7 Q: I: ?( r% ]$ G
}! N+ A! Y v1 [* p) `
else if (yDir == "up") {
1 a2 z8 }7 v; h) J5 t: A yPos = yPos - BallSpeed;
/ z" D- C! A9 p! q6 D }. y8 B3 r8 k1 L% H
else {
7 H, `% I& ]1 m# g, G0 } yPos = yPos;; G I1 a) v" C$ ]
}
' ?' D9 e+ M7 x3 [' L+ s( ? }- w, S4 T& o+ u) M
. _+ M3 u3 P, h. p
function hidetext(){
% i! U# r/ K" Z u( E0 kif (document.all)2 Z8 X$ u& P# U- ]2 h$ w
supertext.style.visibility="hidden"
{1 g6 c5 ]; s5 v- H. Y% uelse if (document.layers)
0 a- x7 h3 g d5 h: ~document.supertext.visibility="hide". p+ C1 N* K, E9 ?
clearTimeout(animatetext)8 k8 O, ]/ g9 Z" Z. k
}- m$ [; D$ o, K( H7 [2 y
6 m% l0 x7 ^) T9 L+ Q
if (document.all||document.layers){
1 v4 m: v4 a" e( l$ n8 Q* Zdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 c4 w& D# |; I- S8 s( |window.onload = initializeBall;
* N# X/ l- J. Z- Q! vwindow.onresize = new Function("window.location.reload()");
( V- I- J6 |" k- l}% S5 G# ~- w& P; p: n& j
2 x+ V6 L. a- S
</script> |
|