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

|
网页之不断弹射的文字-特效
<style type="text/css">5 ~7 D& C6 ~- I4 x
#supertext {* k; e5 [! ^' B& L- o
position:absolute;
; d2 E" E% Q5 L1 Aleft:0;
' U; a1 Z2 Z" o" wtop:0;
1 L1 x+ m& U4 h: [visibility:hide;, T, \4 J$ `& k2 @. n# Z& _( K) Q
visibility:hidden;; i; W2 b) c M* | g
}
; X _/ e% _. T" l& t9 g- T9 I</style>4 x, F6 H* }# n
<script language="JavaScript1.2">& Y& d0 Z, _+ p) W# m
<!-- 改变下的字体的大小。颜色-->: |9 c+ M. [6 o5 e5 s- H3 s6 r
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': G8 j7 K& j( s1 e0 [$ a! _
var hidetimer='';
( k- j8 B- o) L/ K/ ]1 F<!-- 改变下的弹跳速度-->1 `! v+ ^; U9 _# [/ S
var BallSpeed = 20;
6 W& n5 T1 q0 t# B, q9 pvar contentWidth;
' U* {# Q! g" q% Q7 kvar contentHeight;, B1 s' z5 [ x' l/ w, F. J
var maxBallSpeed = 50;
, i8 H' @6 @% A% |7 O+ ?
* b; G) e; T/ G& S, ~% ~ B. t4 z' B. B2 D
var xMax;
$ d$ d- F3 G; f7 \var yMax;
' x1 Y4 ~) k/ Lvar xPos = 0;
( N& T5 g3 [0 A/ Ivar yPos = 0;$ Y1 ^8 z6 [7 u, M# l3 ~) {8 ]+ X- b
var xDir = 'right';+ n7 n3 l" V2 M" s2 I
var yDir = 'down';* G' f# K& z8 J- F5 X; ~$ n6 G: ?
var superballRunning = true;
+ |2 `3 y% X: G! W6 nvar tempBallSpeed;% M1 m9 C; S( l' f5 x8 E' {
var currentBallSrc; _ l# |" [$ R* ?1 ?
var newXDir; S. w+ M; h/ S" T9 {: S7 |0 l
var newYDir;
+ d# o6 X1 s# ~ O$ [; i' d. J
( H1 c6 _; P4 K6 l( G5 Dfunction initializeBall() {
" T Q% c- h6 ~) V if (document.all) {2 t* B8 t, P% ]+ `6 V
xMax = document.body.clientWidth7 y) c$ g3 K3 p2 D0 @/ L* v
yMax = document.body.clientHeight
+ a8 V! F/ B, z4 E* }/ D document.all("supertext").style.visibility = "visible";
6 z! s1 w& v! g! u! d contentWidth=supertext.offsetWidth
( R2 |3 s9 r, G0 ]# R contentHeight=supertext.offsetHeight: p4 R& w: [0 C7 h# ?2 p
}& @) O& }! M! t
else if (document.layers) {
; `7 x6 L1 T& q& [* H1 J" ^) R xMax = window.innerWidth;
2 h. j r* L6 K3 G( T: `! S2 q yMax = window.innerHeight;7 E$ U- F" e4 f
contentWidth=document.supertext.document.width
2 h1 i, m, b/ Z contentHeight=document.supertext.document.height: J7 R2 |, O6 {- | z3 N2 \
document.layers["supertext"].visibility = "show";- J6 U6 K; S4 j; ~# ?$ _4 P
}
5 G' G' M& s0 ]0 S setTimeout('moveBall()',400);/ M3 E, p f! w0 g# S1 \. I1 K
if (hidetimer!='')
) }4 j& d- Q1 \" B) T8 N9 } setTimeout("hidetext()",hidetimer); E0 d2 s' d' O2 w( B
}! ^4 F+ @0 Q& ]! _4 e6 r) D
5 x2 g3 v( G+ o @4 |4 ^4 B
function moveBall() {6 L% A! q- r' R# N
if (superballRunning == true) {4 F4 n# N: O7 x4 g: ^/ b
calculatePosition();
) M" W. N- u2 v# W$ ] if (document.all) {
4 x( l& y3 i5 Y. f! a document.all("supertext").style.left = xPos + document.body.scrollLeft;% R$ C7 H( n5 ~4 c! I
document.all("supertext").style.top = yPos + document.body.scrollTop;4 G* l# M5 k. e3 B
}
! h" ]' Q4 T8 [! T7 e6 X else if (document.layers) {% [( C, ~- e7 J/ b7 {( v5 X
document.layers["supertext"].left = xPos + pageXOffset;
/ m2 f* U3 @3 s1 v b6 y document.layers["supertext"].top = yPos + pageYOffset;
) s( b5 a% d3 K+ G1 F! G( z }
0 R% d" [% ^6 g1 H9 _ animatetext=setTimeout('moveBall()',20);* }* r' C0 J, d! S
} w, n% p: K$ Z W
}' g9 r- h$ `. r e, }5 @" c9 T. {, F
8 \& W" N" c+ \% e. I5 i1 B8 W
function calculatePosition() {
% \3 `7 z* a1 s if (xDir == "right") {
; Z' E& p% m2 p) I& L6 } if (xPos > (xMax - contentWidth - BallSpeed)) {
3 s5 Y% a$ @' L( x8 S xDir = "left";" T: ]( @* X! V2 D& B
}
, f* e+ Q0 X) _ }# ~4 H. Y) {( f& m) `! S2 Z! E
else if (xDir == "left") {
0 V: N! J7 B1 Y% M if (xPos < (0 + BallSpeed)) {; ?0 G3 V x- l, p) }! k( r
xDir = "right";
* k% v( S& Z+ W }# P4 b; u: x" m: h0 y+ \$ Y
}
% Q* `% H$ y: G2 x7 }' S7 @+ F1 { if (yDir == "down") {
6 G- J( t j* i. q5 b, N if (yPos > (yMax - contentHeight - BallSpeed)) {' d; U! f2 [$ }
yDir = "up";; a& q2 N5 l5 l3 ~
}
, |6 a. S. A# Q3 b V }" K/ u! I/ `. u8 l6 n$ X' H% O' ?
else if (yDir == "up") {
. ~( v- u0 K( h0 L @$ Z6 G/ u if (yPos < (0 + BallSpeed)) {
: x) @/ V! ~) Y5 Q; ^; [# ?) y' c) J yDir = "down";
9 r+ w* {9 `, f8 R+ r }9 y) p$ h+ ]1 P3 O: q
}/ M! g2 L$ s! J) P7 S# b8 v
if (xDir == "right") {" _+ e& T1 d* h: I' T% q4 ^2 p
xPos = xPos + BallSpeed;7 v* r/ k& k. i, o
}
7 B4 m# a9 v1 F6 {5 k! @9 O% b/ ^ else if (xDir == "left") {
% m' _5 Z6 l6 H7 [# P6 w' f xPos = xPos - BallSpeed;
$ k& V: ~& j+ [. h8 g# e5 c& j6 I }( q2 M3 U8 j7 {: \
else {3 |5 Z. n" D) t# [9 i6 n$ U8 q0 b
xPos = xPos;* U9 M8 Y: Q% h, M/ K
}2 O8 `, r2 ~5 V3 _8 _7 G
if (yDir == "down") {' O0 A) t# S d7 o
yPos = yPos + BallSpeed;
' M5 \6 R1 v* n# D! n0 ~ }
/ ?0 p" [" u0 t3 M$ F else if (yDir == "up") {2 A2 C* w3 y4 j9 n# [
yPos = yPos - BallSpeed;
o' C8 P' [4 \3 W2 [ }5 P- h& M4 Y p3 f# m0 ]$ n
else {
9 e: ]) Q! o2 L yPos = yPos; C& _+ U+ h6 I% Y: m, C7 o. x
}
6 C" F3 N' j' Y* }) N }
9 \5 Y$ U+ ^8 p: U* L$ t; @' Z/ \; r- k3 Q" p8 j" W1 n3 h
function hidetext(){+ E1 ~4 N1 K4 ]2 v' a5 ^" t/ b0 n8 y
if (document.all)
+ V0 W3 `$ r5 b: P* k3 F3 |7 W! lsupertext.style.visibility="hidden"* F% T: `/ F+ E# q' Y* a2 L1 }
else if (document.layers)
0 D5 f4 n; t c$ H2 Ydocument.supertext.visibility="hide"
; q1 \$ \* Z2 j: B I' H" QclearTimeout(animatetext)
, A8 n$ X: U! U}+ j9 M) _- P' L* o! K1 ?4 ^2 H0 @
8 F3 ]& C/ H' x! F+ uif (document.all||document.layers){
1 w7 c3 A# \$ q& D2 Wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>') I9 e; V3 y; B& P
window.onload = initializeBall;3 {$ E4 T% g8 b9 E8 w0 @* P
window.onresize = new Function("window.location.reload()");3 q- z- [. [5 _( \
}
9 h2 v$ C( \' x* S
' i6 B9 e8 t% Z4 c `</script> |
|