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

|
网页之不断弹射的文字-特效
<style type="text/css">
K+ }! q+ j, w% i" H#supertext {6 D. t# f' m; P* i* T7 a ?
position:absolute;% [- H9 z, S1 L4 |; @$ O3 N9 E0 [
left:0;& j# X& s2 @" n; k' Y
top:0;
3 y7 ?0 H9 b$ G" g4 Ivisibility:hide;4 q5 c' R( b) d5 }# Q7 @
visibility:hidden;
4 p/ R' |" Z% w2 [}- t9 {. w* a& I/ y+ }6 t* O2 y
</style>
# F' L6 p$ U7 m<script language="JavaScript1.2">
9 n1 [" p* E8 m G& r2 m6 w<!-- 改变下的字体的大小。颜色-->
9 y0 [, {" w. A9 K: v% f, ~var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
, Y4 w/ {6 H9 c+ ?/ [( nvar hidetimer='';
" m9 d2 ]# x1 `4 w- N3 Z3 `, [1 }1 q' _8 F<!-- 改变下的弹跳速度-->! S1 c% } z' B! K d
var BallSpeed = 20;
: K. A% E0 x* K/ yvar contentWidth;
& Z9 \. q& Y6 R2 p6 l5 A* ?var contentHeight;
! X* F1 M8 L1 E/ `( t3 }var maxBallSpeed = 50;, V" k/ u: q) Y0 `; d
6 ^& E- h' O r1 s5 @3 C2 q3 C# w
3 K' b" _5 f. k5 C+ T" f, O! dvar xMax;
% O; C/ c: E& Y$ A# qvar yMax;4 ^ W4 H7 _$ |5 _, x, c% M
var xPos = 0;# R( ?: ^6 w% D( g# b; i& u
var yPos = 0;# n5 k1 S7 o' V* g5 v6 l5 Q$ h
var xDir = 'right';
, a! h0 H, F* l( hvar yDir = 'down';9 l6 u2 |' m: R
var superballRunning = true;
) w0 u4 ?' |* ^8 I& k# Nvar tempBallSpeed;
- Z* W& {: \2 ]$ d& ]8 x& @' m3 gvar currentBallSrc;( J5 J4 H0 }1 d9 L9 K) L( H2 o2 K
var newXDir;
6 \, q# T! W1 k1 Z3 ^& e& evar newYDir;
, X# l. x- e8 v) a! w o0 p1 y8 R$ N7 [5 f- @
function initializeBall() {
2 e# u5 e1 ^: M' p9 U& j, q if (document.all) {: k4 W1 W2 I9 F" G2 K# r1 @. c
xMax = document.body.clientWidth F* \( P8 N+ H. i
yMax = document.body.clientHeight
' |0 t. l# p3 ~! u q document.all("supertext").style.visibility = "visible";, r# q& T6 d8 W9 g- e
contentWidth=supertext.offsetWidth2 l" E- @9 s+ n4 L
contentHeight=supertext.offsetHeight
% W; B, R/ d h4 ?/ X1 b }
& T3 V* l1 ?/ h0 x else if (document.layers) {
1 y, x0 Q1 H" i xMax = window.innerWidth;* W3 d2 K* u, a
yMax = window.innerHeight;
& k! Z5 k+ d" [ contentWidth=document.supertext.document.width t; \9 e) C# n6 V
contentHeight=document.supertext.document.height+ f e( v9 ]( z: V4 ^5 L
document.layers["supertext"].visibility = "show";- k8 C/ p" b; ~- M! e6 \) r, h3 Q) B
}
: U4 R& J d8 W+ M setTimeout('moveBall()',400);0 L, D" c9 N1 F2 A( L9 M+ k" |
if (hidetimer!='')
1 U0 \, v$ [5 c$ z2 P6 @ setTimeout("hidetext()",hidetimer)
' Z, t" e+ k2 }* [3 \+ R, B }% U: ^. I% W' `
) N% u4 t3 d; w {, B: e
function moveBall() {3 n( W8 t0 U: F! k# p1 j" |
if (superballRunning == true) {
9 p/ q8 {9 c+ j' Y) Q8 F calculatePosition();8 o8 w& `; x8 j4 d) a
if (document.all) {
3 R7 p* v* ^/ m0 h( U2 j document.all("supertext").style.left = xPos + document.body.scrollLeft;
3 E0 U( k) \( P6 e/ v4 s: K5 g document.all("supertext").style.top = yPos + document.body.scrollTop;
$ ?" R' ^* Y2 s( ]4 X+ y }" S, f' N$ K& R, P
else if (document.layers) {' G4 D( B0 m/ [' [- `; m+ J7 b
document.layers["supertext"].left = xPos + pageXOffset;
4 ?; f7 s+ L/ B# i6 U. r document.layers["supertext"].top = yPos + pageYOffset;
! y( B5 x% O5 v2 \9 B% b }
5 R! s) H- R, p* u' \- ]+ `1 v animatetext=setTimeout('moveBall()',20);
2 b7 y/ e' D y. ?# ` }
0 Z% v L- a4 x- \2 |( W3 ~ }3 b, n( s- b% k$ V/ J
9 Q/ [. ]* {) m8 Q2 [ ofunction calculatePosition() {
" n, D4 v7 {3 u0 N: p. R8 l) z: q if (xDir == "right") {2 h9 I, G! C7 x$ b9 b
if (xPos > (xMax - contentWidth - BallSpeed)) {
1 Q$ K6 L" m0 q# w' }: P. M xDir = "left";
. O- p6 \; d S' V; |4 r$ O7 f }3 X4 L; J' g2 `
}
5 |0 d; p! U0 \" C" l" ~ else if (xDir == "left") {
! \' h% t! ?2 m if (xPos < (0 + BallSpeed)) {6 n; f3 r; M; {0 F2 | ?
xDir = "right";. v! ~% ?. |) ~
}
( x( T; ^3 z4 X+ i; q. K }
, M* [4 U2 d) x( b if (yDir == "down") {
; E. o* h, O$ E/ G) C/ m if (yPos > (yMax - contentHeight - BallSpeed)) {. t& G4 X/ F5 G/ ^
yDir = "up";0 h ^( Q+ q/ J
}) x9 [3 J$ P6 [ {) \
}
) |% F) b ~9 p3 E else if (yDir == "up") {* o/ a6 u$ W, `' L. c5 v
if (yPos < (0 + BallSpeed)) {
* y) x, |3 R8 h yDir = "down";. }6 u/ t9 U7 g: h4 b3 Z0 O
}
) k" P5 S' G7 }7 x! U }6 l& A' v2 X m* x+ r. t# y
if (xDir == "right") {
6 i! G5 x6 P9 ?( m- c8 W xPos = xPos + BallSpeed;
m- t u& f a }5 V" ?: G$ B8 j; N& I( r
else if (xDir == "left") {- O) D2 z2 z) C
xPos = xPos - BallSpeed;/ q" P" h0 f! a( N" ]
}$ V2 g3 A, x) N1 c5 J+ Y5 d! D
else {. R& X& d, e0 P) x3 `
xPos = xPos;
( J* b6 R; K2 i( r }* O! O- q. E A
if (yDir == "down") {2 z+ ?( i4 u/ u4 ?% c& o
yPos = yPos + BallSpeed;
! V! X, B& S H" D }
4 q4 i$ W$ U8 _$ F1 N) O else if (yDir == "up") {6 M/ A' V" f& n1 w1 `' P( V* w3 w
yPos = yPos - BallSpeed;9 K. u; g$ v2 L$ @# g+ a
}
! f4 b; b9 A0 d' M' y else {. P% ~% ]8 Y2 x3 j/ U9 N9 X
yPos = yPos;' y8 I5 c# F9 N' u* V- E
}" W: ]+ S8 d# v6 S% N5 S
}
2 W7 E2 F! w: ]' V* Q) [/ r! w$ R$ p: [( D8 c9 e* d
function hidetext(){
8 }! E o/ n/ j. z& Rif (document.all)
; l$ Y/ t& [) H/ ^1 i/ [7 Ksupertext.style.visibility="hidden"
9 z8 t. e# `& Helse if (document.layers)
9 Y( L1 X% t8 T" j9 {document.supertext.visibility="hide"
* ^' J9 l8 n3 E! N' R! q* ]+ p6 PclearTimeout(animatetext)2 p( S2 [9 T" s. F1 @
}0 r+ \) D% |' d) T
H' ~& S/ ?6 P% C. W
if (document.all||document.layers){: {5 j9 W- R1 H5 Z* P
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')7 s6 ?7 R% C, o; W
window.onload = initializeBall;
0 S4 v q8 s6 y7 m. J% Dwindow.onresize = new Function("window.location.reload()");: N' T0 h1 i) O& d! {
}
! {6 P8 ?: A( B( I" C3 z6 x- Q
. W$ m# n ]3 s# o$ l3 T</script> |
|