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

|
网页之不断弹射的文字-特效
<style type="text/css">$ s9 h; N, O8 R
#supertext {; n& b6 i8 }' V
position:absolute;
. @$ ]" w* A2 p2 Y" sleft:0;4 b( O& T5 d3 Y) l
top:0;
% ~; ?4 x5 w7 Avisibility:hide;
1 z( I+ K. G5 i6 b- N: B# ]' ivisibility:hidden;, Q% y6 S/ I" R- j
}2 {; M! R1 H5 X$ C. X' n, a, Q1 F
</style># Q+ k7 i5 c B4 t9 J$ u* I2 L4 T
<script language="JavaScript1.2"> ?; o" \+ _# d; D$ @
<!-- 改变下的字体的大小。颜色-->& Y) } j* _" t1 h, T
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'* S- o+ h1 _4 K( h+ t* G" ^
var hidetimer='';
- Q( C3 @3 n: Q5 a, O! B. S1 F! M<!-- 改变下的弹跳速度-->+ _. v1 @4 \7 z+ m
var BallSpeed = 20;& c) W) i3 _! l: a6 B4 ~' c8 Q
var contentWidth;
# X5 ~& ~3 \4 Y! lvar contentHeight;8 a& s' U- u4 L1 H; S
var maxBallSpeed = 50;
5 d: s* g' g9 e4 E! c- X
* M' L( i5 v9 m/ V: g, T9 m( V7 ^+ {; P! A, l- A( i$ i) Q
var xMax;
0 o, V* i8 T. j; |. i. Kvar yMax;9 `1 \5 J9 d. e1 k h! Z
var xPos = 0;
: z: r. H% q; F; [" A+ bvar yPos = 0;8 O0 Q; z2 a6 S9 E* f2 B
var xDir = 'right';1 F6 v" h2 m( [0 t; g
var yDir = 'down';! ?8 k9 L" o- _/ b: | ?- ^
var superballRunning = true;. l& i0 H E, F4 T
var tempBallSpeed; e4 U+ @7 ] c, U$ u7 D
var currentBallSrc;
3 k2 @) N/ H* ^. O6 k7 uvar newXDir;
7 B4 ]1 X8 ^% t) [5 [" qvar newYDir;
v! C- ^3 ^' M* @4 `8 B
+ T3 c5 x9 z" M! gfunction initializeBall() {6 @, q6 O: h! R9 B2 J. v# r! b, s
if (document.all) {6 S4 E6 o) E/ ^1 S3 K _
xMax = document.body.clientWidth1 g/ O) @! B' J/ u, K+ `% e+ S
yMax = document.body.clientHeight
0 ?1 U, _: S# Y9 r# F! m document.all("supertext").style.visibility = "visible";; a; k& L; E v0 R8 \ k
contentWidth=supertext.offsetWidth& g% }$ G! Z/ v3 h& s! u- _
contentHeight=supertext.offsetHeight( h2 A. o4 }" M) ?. N$ c- |8 M
}
. \& @2 r* R; `5 q5 ~1 F else if (document.layers) {
! {* }3 R' B# j# v T; {5 ]* u xMax = window.innerWidth;8 E2 w9 E- c! B+ r3 f
yMax = window.innerHeight;
& e- |0 J! n- R8 U2 E# h contentWidth=document.supertext.document.width
3 [9 b( [3 H: W1 X( } contentHeight=document.supertext.document.height) p! g5 I" T h) r' ~$ U
document.layers["supertext"].visibility = "show";) @% y1 S- T! z9 D4 \6 \) q6 Q
}5 z1 _6 |2 J, s9 z2 N8 f
setTimeout('moveBall()',400);) f- s. C6 C) c8 g ]6 a3 a
if (hidetimer!='')- t) P9 F0 }( b4 Q( a
setTimeout("hidetext()",hidetimer)$ g* ~# n% q( d( @
}* K" L* b o* l' g$ e; _
2 ]' Z1 l3 p2 y! o& X
function moveBall() {: G6 U5 Z( O$ O7 I
if (superballRunning == true) {) D6 Z9 f& P. Y
calculatePosition();
/ u9 _) F* n. N if (document.all) {
/ N, \ B7 o% h; C8 l document.all("supertext").style.left = xPos + document.body.scrollLeft;& [7 h& h: e+ `' m7 Y" n* l2 K' {1 A
document.all("supertext").style.top = yPos + document.body.scrollTop;
9 j1 m9 `3 M$ `- `3 `/ Z$ t }
! l1 z) J- I3 ? else if (document.layers) {
9 F; ^% j: p; j document.layers["supertext"].left = xPos + pageXOffset;
4 `/ G$ ^5 G+ [ document.layers["supertext"].top = yPos + pageYOffset;9 u! L+ h2 r5 I, @* n7 d" F! d& I3 }$ U" R
}
& K5 p" M$ \- Q' T/ j5 d animatetext=setTimeout('moveBall()',20);& C0 p* P* m8 D. G+ S1 q
}
' c& X+ Q. B3 N, S6 J }/ P% w6 V/ r8 t: P9 y: o- Y- t' k
2 x" D! f5 M$ P5 w Z/ C( Hfunction calculatePosition() {
, ]# @( `4 r) b# N- T: X x/ N if (xDir == "right") {$ Q: I2 N# }7 f0 Q+ M2 b: A
if (xPos > (xMax - contentWidth - BallSpeed)) {" J" C; _1 ~; T5 e D( ] z9 H0 X* z
xDir = "left"; R- y/ o+ H2 U2 k
}. W7 W9 C% i, b$ r7 F8 u5 X
}
$ k2 p9 `: M2 ]2 L+ m0 @6 _, s else if (xDir == "left") {
7 Y0 W* y* V7 e; C8 D T. W" A if (xPos < (0 + BallSpeed)) {- b6 K) ?+ O* c4 ~/ H2 l" u+ T3 ]
xDir = "right";
0 j& N- p1 s( _5 O }
) g1 _* ?0 w7 S+ ^ }7 F% h, b& ?7 w1 n8 c i! o8 R
if (yDir == "down") {7 j1 v. I) ~ ?. }, w" r# u' z
if (yPos > (yMax - contentHeight - BallSpeed)) {
% t2 m# S9 T1 s" T' `, C+ O yDir = "up";6 U# m; \* l# ?! x# P! v
}. Q/ {! d, ^* W1 G$ i5 K
}
5 x/ m0 {2 t A9 H4 e9 T else if (yDir == "up") {7 I8 C* c, V* ?
if (yPos < (0 + BallSpeed)) {* l( V3 A! q% r0 x
yDir = "down";) {* E1 R- n+ y( l8 ~
}
4 o( x. E9 r0 u' l- t }
2 M. N, i4 m1 `% i/ j9 U if (xDir == "right") {4 [/ M7 x3 |1 r) x, A. p8 ^. l
xPos = xPos + BallSpeed;1 p9 f1 D( s) a3 h7 z3 B% k1 @6 D
}
. z% X9 w% x; G) K- W1 l* j4 Y else if (xDir == "left") {
$ }' m7 o& ]' k2 \# `9 Q0 R xPos = xPos - BallSpeed;
+ _" G& Q0 o1 p) A }4 U- p) d7 h- Y
else {; _2 o) B6 [! v. a- |6 o) {
xPos = xPos;
$ l8 |, s$ t( g3 ~ }, r4 F+ e7 Y; \, [* r2 y' @) m2 H
if (yDir == "down") {" E; V" k! M7 K' V
yPos = yPos + BallSpeed;" ^1 o. I& @4 {( ]- M$ r# v
}* ]1 y9 M( P7 @5 M# i9 X# g7 T
else if (yDir == "up") {' v6 h+ J# v3 |4 \: M9 }; `4 @
yPos = yPos - BallSpeed;8 X; _6 N7 v& H7 H. |
}
: {5 T' }2 F V/ H, ^$ j else {
+ D0 C7 |: j4 d! H& e% y yPos = yPos;
# F( W" Q" o$ p }
" Y# n, }# S$ U! N4 s" I$ T }9 r& v" B8 _4 e9 Q4 _
- }' c$ Z4 T: Y5 c' e! ofunction hidetext(){
8 f9 h" J$ L, W2 {if (document.all)1 a2 b0 ~( `! r3 h, z
supertext.style.visibility="hidden"& q) J8 E; N& S' S; F6 U
else if (document.layers)6 W' e8 x l5 _9 w; c9 w6 q: P2 J
document.supertext.visibility="hide"
8 w& r; J2 @; z$ _$ NclearTimeout(animatetext)
3 ]+ h; }, S: B5 Z" D, t}
% z2 N- C) Q0 ^ ~/ p" K1 ~3 Q5 K/ O) h
if (document.all||document.layers){
' d1 d K+ Z: q" f% |! Qdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
# h! |4 F; j2 p6 e# xwindow.onload = initializeBall;
1 I7 |5 g$ Z4 K% S7 V, nwindow.onresize = new Function("window.location.reload()");
l/ d1 h2 H! c; }7 N}
4 n% h( ]3 z0 l
& T/ [- b/ ]! V7 G3 d$ b* l# e" J</script> |
|