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

|
网页之不断弹射的文字-特效
<style type="text/css">
/ ^9 [7 @) L s2 n( N0 b: N9 P#supertext {
- _" R2 ?& @, E) \position:absolute;/ d& D8 e" E% @/ ?* v
left:0;! f4 U G# @# G& G9 v
top:0;/ Q$ x1 D& T- u0 d- [ I" d% Y
visibility:hide;2 ^9 N' J- O9 e1 n- W3 \! E
visibility:hidden;' P, u& N% W) D, q6 K
}! H' e5 v$ P* n8 c4 s; p! t( _! j
</style>( c6 s/ ^3 h* a( R5 j. N
<script language="JavaScript1.2">
* l4 Y$ t/ d( u: U3 }" O0 j; Q<!-- 改变下的字体的大小。颜色-->* ~) T2 @" ~+ U1 n7 u1 M0 X3 q
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'( A# Q$ t2 K% b
var hidetimer='';8 t2 O, T9 }5 ] w8 L
<!-- 改变下的弹跳速度--> `0 j# P0 ?! r/ h
var BallSpeed = 20;
6 a# x# e* r) k: Q9 Z$ G; @* Rvar contentWidth;* t4 `2 O/ w# D* ?- L
var contentHeight; Q1 ^" U% `+ p" ?4 `0 ?8 Z
var maxBallSpeed = 50;
& n2 k& i0 @& r. m o) t3 q: m
8 Z0 ]& k9 ]# M3 h4 B* a& O+ V1 O8 |. M+ j0 j \7 a4 M
var xMax;
$ o& L X% H& {3 h# E& v. Dvar yMax;" L9 \; ]1 v% x5 U' l' S
var xPos = 0;
1 I B7 o, t6 [* \* Ivar yPos = 0;& O0 J: Q, F3 b$ }
var xDir = 'right';
7 C3 r U, m( V+ l/ n. h, ]var yDir = 'down';
6 K4 S. ?' |, `7 Bvar superballRunning = true;; ^$ X8 _+ Y8 k4 B8 I% @
var tempBallSpeed;
2 V6 o1 [% @" j0 D) [var currentBallSrc;/ D# a) Z/ P/ R( `- h
var newXDir;; E+ Y& q& [2 ~4 O; x, J, |
var newYDir;
$ X" x b1 U9 R, f" u) m# N L/ H( K) r$ o0 n! b8 l, a+ q4 U# f
function initializeBall() {
) u5 Q7 K3 l* l% W- ^' {, H if (document.all) {
! t Y* L2 k+ z. a/ r8 p xMax = document.body.clientWidth6 U! n, T% v+ s5 E" g9 H+ y6 D
yMax = document.body.clientHeight, m6 k0 M d- A7 |* B
document.all("supertext").style.visibility = "visible";
; ^7 |7 L6 Z. Y7 R0 h( }2 V contentWidth=supertext.offsetWidth9 x6 Z) [8 \9 ~/ Z
contentHeight=supertext.offsetHeight
) t: @! Z1 c6 K }: Z0 ]* V7 V$ D2 J! b
else if (document.layers) {- z3 Y% Z5 r$ X1 y
xMax = window.innerWidth;
( C2 O; i2 F+ B4 I4 R4 g" n& L( E yMax = window.innerHeight;
6 p+ g; ~+ I$ Q: R contentWidth=document.supertext.document.width$ ~2 R2 G# G8 k3 y
contentHeight=document.supertext.document.height
- T/ t8 i0 V1 `- [: h document.layers["supertext"].visibility = "show";( ~+ r' ^0 p# c: O
}9 k3 x0 l# N0 {( i, a% i% u
setTimeout('moveBall()',400);
, t/ W3 S3 X4 l5 i if (hidetimer!='')
# S) q E$ p1 |. j$ R$ p! [ setTimeout("hidetext()",hidetimer)7 J( c/ l2 `3 ~) ^) J1 e- w
}
3 S$ y) g, @1 ~; U( ~8 n$ g. ~
3 A+ F7 a- {! bfunction moveBall() {
& |8 |( C: m1 @! @ if (superballRunning == true) {, S' X" m4 _* t
calculatePosition();1 s/ u3 U$ q* W3 ?: c: s2 g
if (document.all) { W p9 M4 d: p5 h
document.all("supertext").style.left = xPos + document.body.scrollLeft;* Z- `" I8 }/ ^% p
document.all("supertext").style.top = yPos + document.body.scrollTop; `+ p, U- G2 T! ~, S* a; ?; L
}
o) ~" {& }5 l; R' f else if (document.layers) {
2 {" e. _8 B) W4 l" x document.layers["supertext"].left = xPos + pageXOffset;7 h2 ~0 Y7 j2 Q3 C
document.layers["supertext"].top = yPos + pageYOffset;
a( c/ F K. {+ u Z' F }
2 z C& r! W, x8 @! X h animatetext=setTimeout('moveBall()',20);
5 ^" ^* U8 [" L7 c0 X }
! j7 S* `6 z g% d( o. _, F' N }5 m O2 A3 Z( ?+ U8 g; f
7 G% j9 C; X# @7 Cfunction calculatePosition() {
5 [$ l) j8 z/ ], p# w6 ^/ P( l! z if (xDir == "right") {6 `- v4 F2 {$ ~' k
if (xPos > (xMax - contentWidth - BallSpeed)) {8 h: F+ {# m" D# f' P$ A2 T
xDir = "left";9 ?$ q3 ^: [; a) b+ l- I
}
8 j# a8 Q& N; |0 b }
/ ^. g- W6 s3 @, Y9 f9 L" R: R else if (xDir == "left") {
) D9 {* U" v* q5 \8 B$ n if (xPos < (0 + BallSpeed)) {" M+ _2 l: p2 S8 g. V
xDir = "right";
5 Y! W# L+ d: L }! @ r2 r% Y/ F" l0 u5 a1 U
}
5 H' J: S( }8 Q$ d if (yDir == "down") {
6 d3 O! ]3 Z- N if (yPos > (yMax - contentHeight - BallSpeed)) {$ `2 M- w) C/ o4 I: ?" G
yDir = "up";
9 x( O! {0 {& X' D }
" P9 y I9 t7 `5 E }* C. m- E r; S6 Z
else if (yDir == "up") {% `2 a' e8 c! ^7 N2 ]7 T) [( R0 T" n3 ~
if (yPos < (0 + BallSpeed)) {
" I1 x5 Z3 o* d( c/ x! s+ I. { yDir = "down";+ |0 ^: c( r K% P" b2 [7 ]
}
) A: j$ _8 D9 m: h8 f }, k: W2 I: I w5 U) ^/ ?2 a7 F+ B5 [
if (xDir == "right") {
. W# Y$ o2 I% h; z% W xPos = xPos + BallSpeed;7 S1 ?; I; R" s6 ?& ?: D" ^
}& B7 k" W8 X( k( l& Z3 v( H8 k
else if (xDir == "left") {
1 u9 _8 B7 D0 o xPos = xPos - BallSpeed;
5 m) @" i- \ I# \! r* D" | }
8 g$ [( a9 d% f else {
( c2 X3 p2 ` m# ]5 M xPos = xPos;
x2 {& R1 f I/ @4 s& P5 p }2 }' f5 [8 U8 K+ P# |- g
if (yDir == "down") {: l' q; t; A8 p/ Z' I' h
yPos = yPos + BallSpeed;
+ I9 x4 D5 L* h+ J. w }
/ i. ^) m" M5 j; c, `. `( T else if (yDir == "up") {( A$ D" m2 c- d3 s4 g0 V
yPos = yPos - BallSpeed;5 y0 b% g1 W/ M; s1 P" }
}% {1 `) @! H1 M2 r: Q
else {
8 L9 e% S( G9 p7 Z+ g; T& e" e& k yPos = yPos;- J7 R; |1 j7 E3 j
}2 G: W/ A/ I3 w$ y
}
% R$ U* J9 _9 n( U& x E- c$ Q8 E3 y+ x- v: o+ m( d% D1 ]9 R; J* \
function hidetext(){
9 N4 P3 o- A+ p8 U+ e) u- K: Rif (document.all)$ c' ]2 W" ^) F& R
supertext.style.visibility="hidden"+ U+ O7 T1 `/ P) `( ^" O
else if (document.layers)
" @0 Z x. ^. d* rdocument.supertext.visibility="hide"
3 k6 b+ ]! Y9 R! AclearTimeout(animatetext)* w H, H- w- }$ A6 ?' W" p+ \6 [
}/ I& D* _! z& }+ B! h# F
6 B( R# }1 j g, v8 w
if (document.all||document.layers){2 Y, G; ]# }. B1 k2 W
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')% d: g1 Y1 e+ C: z* a: h! c6 h
window.onload = initializeBall;6 ]& N" p! O! t3 t+ S
window.onresize = new Function("window.location.reload()");
$ [9 u, I) W9 [% X |; z% I}
( x+ m# k" T0 K1 e5 G% u8 M
+ o8 P# H% `3 C D6 @3 U5 f0 Q* b</script> |
|