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

|
网页之不断弹射的文字-特效
<style type="text/css">! q9 ?) l" }" z# S& i/ ^/ A
#supertext {( v5 @7 D2 ~% ^( E0 N' }0 [! ]. {
position:absolute;: n3 i& s9 v$ p5 O
left:0;
4 d N! t( _) A8 r7 Z8 \) Ftop:0;
; Z, X/ x1 I- e+ Mvisibility:hide;
5 q. n" s8 \% Avisibility:hidden;5 v2 F9 a4 u- G8 [
}) P" c; u: b8 b: Q' ~
</style>2 Y, i) x$ C3 v/ J# Y: d
<script language="JavaScript1.2">
) S O5 ]( u# [<!-- 改变下的字体的大小。颜色-->
1 a8 l% ]1 _7 @* b; \5 e& v: Evar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 u% e& s) O, {" ~1 h6 p- x7 uvar hidetimer='';
! H; Q4 |$ L, y; O R; q7 b: O<!-- 改变下的弹跳速度--> [/ K2 l: i3 x/ l: j8 ?) y
var BallSpeed = 20;2 h8 c& o4 D8 c- r/ }! j8 f; s3 H
var contentWidth;
/ l- k" G+ Q1 R) @. q4 z& f8 I1 g! Kvar contentHeight;
3 v) c" q9 h& _& kvar maxBallSpeed = 50;
3 ~6 Z) Z/ @. r- j+ l' j3 I" g( J! F5 M/ c. Q" t+ E2 U. @$ K. ?+ Z
8 F% V8 e$ R7 kvar xMax;
/ ?) I% R7 E& F( N2 h- [) ^. W; Bvar yMax;
: X' c! [5 u# \8 A( g& K: dvar xPos = 0;
7 t$ k$ R: r9 q1 d, Zvar yPos = 0;
- o- H2 ^0 ~% q) s; G; _var xDir = 'right';7 ~' `7 t7 c [: C% {, i. b
var yDir = 'down';
# O! V3 s, J" J' G _- o/ ~var superballRunning = true;
* H9 I2 I2 a |2 m1 Q( H) P: `var tempBallSpeed;" K6 c* q3 c9 J8 D" [2 A5 H( J
var currentBallSrc;$ w+ |, a8 a3 M
var newXDir;
% T/ K$ c$ r: E- ~% E4 U* b* |2 Fvar newYDir;
, I" ~( d' f4 M( T" M l4 a; u/ w& }+ X; D- s) s; R1 D0 r
function initializeBall() {
& }1 M! n$ w( c3 u5 @$ V if (document.all) {
6 V) c* W- x! X xMax = document.body.clientWidth& k; r% W2 c2 A
yMax = document.body.clientHeight: I! y, B y6 ~; e+ c
document.all("supertext").style.visibility = "visible";
9 ?3 ?, C3 o2 H6 Q! X; ?' W% p contentWidth=supertext.offsetWidth6 k) @$ n# t' x+ N0 V
contentHeight=supertext.offsetHeight: a9 J. u/ ]& y( A
}% h- M7 {) `) |( P8 N; k4 K
else if (document.layers) {
3 e4 C ]: C2 U" ?5 y: X7 X v xMax = window.innerWidth;% D% C3 Z( x. Y+ `" l1 L+ J( R2 a
yMax = window.innerHeight;( g2 S$ T$ S: w$ E& s& V6 x! ~/ P
contentWidth=document.supertext.document.width3 q- H2 ]. T8 G5 @& u
contentHeight=document.supertext.document.height
, s6 E+ V- N. a( G7 u8 x document.layers["supertext"].visibility = "show";
0 s$ f( z1 r5 P6 c8 C }6 x0 V ~1 l/ b U. T' f3 S
setTimeout('moveBall()',400);
" I2 a( T6 i; M1 j( d if (hidetimer!='')
; O6 D: z- K, A* t7 b setTimeout("hidetext()",hidetimer)* ~# w% l% Z5 w7 {2 V4 g: L- p# E
}
. K, S# f6 Q0 d' q
7 z0 K! F' z2 r* j) Pfunction moveBall() {2 S/ A" ^* r! n0 e
if (superballRunning == true) {
! f# Q; K$ K% f3 @ calculatePosition();
. A/ g$ O+ U7 C: d4 m if (document.all) {
2 C2 f% b9 j# C8 `/ ^ document.all("supertext").style.left = xPos + document.body.scrollLeft;
7 b! J! n% ]5 h7 a document.all("supertext").style.top = yPos + document.body.scrollTop;
6 O1 s$ n. M5 |, y4 f6 x2 H4 h4 Z }
# O3 n& K' T" p: q# o. r6 \* I else if (document.layers) {) w9 |- U! i2 P6 Z) h. T: j0 h4 y1 c
document.layers["supertext"].left = xPos + pageXOffset;
5 Y0 r5 R4 n; J7 Y0 a( b' k document.layers["supertext"].top = yPos + pageYOffset;9 I9 B ?" A( R: S
}
+ V2 N9 m0 b8 w. J5 W5 m4 d animatetext=setTimeout('moveBall()',20);
" z( w, F' w' U. v [ }4 m `2 I& A% @' J7 x+ k
}' U0 m+ W1 m* U v6 q# @0 b# I
7 D8 R) \' E' J! n$ j* P/ l$ C' Gfunction calculatePosition() {
& M: X ]) H4 @ if (xDir == "right") {, @5 W0 E# J# m% U4 \/ M' o p
if (xPos > (xMax - contentWidth - BallSpeed)) {
3 e3 j5 N8 z0 {2 j xDir = "left";, N9 m) S. ~7 C# O: D" b% W
}
( t' F$ a' [5 M$ s }3 Q" x( u n( p0 x; N! o& w2 q
else if (xDir == "left") {6 K6 G8 S8 |6 j& G0 Y3 u8 Z* g, g. y
if (xPos < (0 + BallSpeed)) {
+ A: r9 i8 R/ a, d xDir = "right";
! }3 h: h1 h6 q$ w }
& B3 E' A0 {9 x. e$ r% U4 ?, o }) X$ ]% ~; A7 [" m% K: U; o
if (yDir == "down") {
1 G0 A- }/ ?+ I' S' w3 }. M! c if (yPos > (yMax - contentHeight - BallSpeed)) {" Z9 N) K$ l8 P: H: X, v3 j
yDir = "up";
0 N. W+ c' \( R6 j* r }
) W: W: ~6 ]! \+ X }
; K% ]4 |* X0 S9 i& x8 V else if (yDir == "up") {$ K! d9 D& S/ t4 p
if (yPos < (0 + BallSpeed)) {
4 S. M2 V7 L: {& f1 @& W yDir = "down";. W& Q9 k8 Y7 U# B
}: p* G' Y( N2 m9 x3 t
}
' p0 Y6 ?2 E5 z3 s4 G& \ if (xDir == "right") {! @, H, q( w/ m/ F- o4 ~( e
xPos = xPos + BallSpeed;' c- Z' m5 i; m) ?" |. V
}3 D0 R% S% j1 o7 @/ K# q) v
else if (xDir == "left") {
; Z w0 V T. n3 { xPos = xPos - BallSpeed;/ Q1 C2 [5 W1 t! A% r
}
5 D4 {6 |; Q" B+ V else {
# ^+ o g1 {( U1 E/ ~7 l6 j xPos = xPos;5 ^) i# g. Z* n4 Q9 Y" R1 u
}" e$ [, l2 S% T
if (yDir == "down") {* b; S, B+ t0 ]* ]# k
yPos = yPos + BallSpeed;1 N1 ~$ M) U: B, S9 Z+ [3 N+ q
}
% }$ F# l B& A else if (yDir == "up") {
1 T1 n( b; R$ J3 b4 x8 o, E yPos = yPos - BallSpeed;
% ^- F7 o% K# q( i: I3 G7 y/ x' c6 S }8 _0 f& `. B4 i
else {. I& n" g! c2 j; k( y( f" a
yPos = yPos;
3 u9 I9 b; s5 _ F. i9 t" Z) o }3 h- S0 i, p* Y1 P
}& `3 {: g, F" B% J L3 O
7 I* [7 O+ x6 V$ O, L& m0 F% I# x3 Qfunction hidetext(){* [9 Z7 N& p2 s. k$ d% k* n3 Y# _
if (document.all)8 Y/ y% ?" g: [& R l* c
supertext.style.visibility="hidden"3 F: @, A$ ]. D1 V; W4 w
else if (document.layers)
+ x7 L$ g% E' A4 }) |6 |# U' N! b1 Sdocument.supertext.visibility="hide"
3 W4 D1 Z5 y& V$ bclearTimeout(animatetext)' G8 r* N& F- f9 ~7 ?
}
) [: \! q5 C$ e/ y7 Y" s5 h5 g& n; J: u8 {& V/ I/ f6 H
if (document.all||document.layers){% w4 e0 y' L8 Q; I8 \7 ]6 E$ }0 ~. |% s
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
0 A8 e! F2 D! L( E( wwindow.onload = initializeBall;" {/ t1 e- ^+ P% R7 q6 ?: f
window.onresize = new Function("window.location.reload()");$ H+ I# a/ \5 _
}
. K% s6 g" \& ~$ M E
" Q! W# w1 X! |</script> |
|