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

|
网页之不断弹射的文字-特效
<style type="text/css">" q/ I6 [/ }. D; t* e
#supertext {
) X ~/ `$ j2 I- u& `position:absolute;% G: ^9 P, U8 |9 l
left:0;/ _6 I. ?! ^* U! P# x' a9 C
top:0;
8 i- \" V7 S8 b) K: U& kvisibility:hide;
7 K( z- B; Q5 F; k' xvisibility:hidden;
% A1 `# w+ }% o9 q! }+ `}
$ F1 \" }& d- \ }</style>
! r" F$ g6 \" |; g$ g! H<script language="JavaScript1.2"># D" N, H& a5 c; T
<!-- 改变下的字体的大小。颜色-->
' d2 N# h+ L2 l& P9 Ovar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 r. O. M3 \( J" h; H9 ivar hidetimer='';
! \. v' I( L& `2 T& b<!-- 改变下的弹跳速度-->6 Y# G: H# y. h R# w$ c2 a6 z
var BallSpeed = 20;
! y7 q+ h+ f4 z7 p$ evar contentWidth;6 o+ e2 i# N* |3 t$ _/ f
var contentHeight;
. A1 W% F; D* fvar maxBallSpeed = 50;
6 e6 x4 B. A$ _" m5 O& p7 y4 X6 M) l4 j0 V+ T7 N) s4 Z/ R
' K" G' p; c: g% g* nvar xMax;% X: T' ?4 ^) X$ b l, |
var yMax;8 \9 D+ A' B1 t0 a- S: W" D
var xPos = 0;' S$ J5 T4 k# d6 \
var yPos = 0;8 v! K) R0 s9 r) G7 q) J9 _6 }
var xDir = 'right';- `9 t9 i. @( d/ w2 R
var yDir = 'down';& e2 r7 h) {) M3 e) e5 Y9 N# i, p7 l
var superballRunning = true;+ C) u1 Q5 e6 Z/ \' J
var tempBallSpeed;
5 ~3 H; F8 Y U9 ~$ L6 \var currentBallSrc;9 A- K( z0 }" A E1 Q; A
var newXDir;( Z& n/ q B0 y* ~- O. E
var newYDir;, ^/ D) ^' g+ X$ v d
. v L3 z( G3 l& O
function initializeBall() {
% @0 W1 ~+ o# s6 L8 ? if (document.all) {
8 o9 b/ k8 u# a( ^3 c xMax = document.body.clientWidth
4 s: Y# m. G2 d yMax = document.body.clientHeight. d7 p* x$ G9 r% i$ c) `
document.all("supertext").style.visibility = "visible";
( v6 R5 i8 i) P. G M: w- h contentWidth=supertext.offsetWidth, Q5 \7 L* v5 L% |( {8 D, r& h2 N
contentHeight=supertext.offsetHeight
. P9 s% e! L. k. ^& i O0 `! D }
# c. O4 W3 H) V( a6 \' s8 Q else if (document.layers) {. R3 s5 v& s% N# E1 b& p
xMax = window.innerWidth;: A$ I6 [. F. M! x
yMax = window.innerHeight;
5 y1 c' a( [0 T7 ]2 t contentWidth=document.supertext.document.width
( T0 [7 q2 a! J8 C& C% Y contentHeight=document.supertext.document.height
) a. f3 ?! x; |$ C' n' ~* f% l1 E0 n, G document.layers["supertext"].visibility = "show";# ?& V. N% [- I: ^- v8 J
}* I, D, E+ R) x8 _% h# n
setTimeout('moveBall()',400);' _) j) O s4 d" [9 s4 X; w
if (hidetimer!='')" D! @+ D8 x. ^* i& Z
setTimeout("hidetext()",hidetimer); L- G( _5 |: O' |" Z
} m* i" g8 N( w! K( W' U& \
" D [0 ]5 a( w. @function moveBall() {3 R% \; n( ?% ~# e& ~% g1 |
if (superballRunning == true) {
5 _8 x+ F% a8 N" g! G T5 g# N1 ? calculatePosition();( v7 n) Y1 T! z7 X% s
if (document.all) {
# W S8 z# h$ I1 a k8 @* R/ t document.all("supertext").style.left = xPos + document.body.scrollLeft;1 h: I. n4 m0 v. A5 o. e& u
document.all("supertext").style.top = yPos + document.body.scrollTop;
$ U# z' D8 W; t! U }
! J$ i ]/ Z9 k+ \ else if (document.layers) {
, N8 ^/ D1 |' S6 R document.layers["supertext"].left = xPos + pageXOffset;7 c, e6 |4 I9 T! ]# J# \ X3 ]5 x
document.layers["supertext"].top = yPos + pageYOffset;
8 Y# \( v8 M- ~ }
' \" E; U5 a3 T# f0 K; } animatetext=setTimeout('moveBall()',20);* n+ h* M5 D( f/ l; T4 o
}
- s8 v; \: y; c% ~ }
$ A6 X7 i: Y2 t8 m; L, L' x: E! q8 G, u* M# P8 t
function calculatePosition() {
) S* \6 q2 H' Q# Q if (xDir == "right") {
. F' M! W; ^- Z3 ^8 H" o/ {, M6 R$ y if (xPos > (xMax - contentWidth - BallSpeed)) {, n9 U w G/ s. R
xDir = "left";
( G) B ?1 a: w% j1 V7 I }9 R3 ^' S/ V$ c0 Q
}
3 P. ~* [. r' J' b. S0 F& s9 B else if (xDir == "left") {
$ H% h. W1 u" s) L if (xPos < (0 + BallSpeed)) {+ E: n$ H! g7 y( p
xDir = "right";
6 j+ I$ S( p- V3 x/ k }
( }0 v3 [! m r) Y0 S }( B4 r ~% h9 f& R8 G, f- U3 \
if (yDir == "down") {
5 ]( O7 a g6 u' ]; h0 }0 R if (yPos > (yMax - contentHeight - BallSpeed)) {
1 `, c2 Y) ?, ^* L yDir = "up";
/ u$ o6 f. e; @$ M1 o9 H }
8 L4 v2 @# U# G. l }
2 o% a3 y$ V* L2 {* u! A else if (yDir == "up") {2 p' S5 W* i: h+ K- D& s" Z
if (yPos < (0 + BallSpeed)) {" z5 X! }( i6 g2 u; h( Y
yDir = "down";
# O/ ?& n2 x& ~. @% r }
3 O6 Z% v; h( i2 D! P9 k, t! N }* n) Y j5 c2 i# Q
if (xDir == "right") {
4 P H0 M; l: F- A6 w" h% r0 u xPos = xPos + BallSpeed;* A$ O; z% M+ M' T' C
}2 N% D- _- R* ~1 |
else if (xDir == "left") {
+ h, g: e1 T, F2 r- N xPos = xPos - BallSpeed;: A% |: G \- B& S$ U' E- {
}
- c: ~( E- x& a1 g9 ]3 C5 v% p else {
8 R3 w6 o" A! n6 ^ xPos = xPos;# B/ _3 x' b" N; i+ p) }( b
}' d1 }3 I/ ^- Z0 x$ b+ d8 `
if (yDir == "down") {
: y3 u O2 k. ]( Y5 L yPos = yPos + BallSpeed;& D# S* w; [* [. o" J
}8 {) w6 H" w; d- z, H8 ?
else if (yDir == "up") {
( L- z4 H0 i6 |" Y( h3 ]/ ~5 t yPos = yPos - BallSpeed;
" Z/ v+ G7 e: l& c }
; z$ D r) R/ Z9 [) S else {
4 e8 u1 ]& H3 x& @& K% e yPos = yPos;
5 ^% F' x _2 ]) b* x' e } T' `) d7 F% z5 x* S, z
}7 p# d& W8 l+ m c. D [ Q- r
! {" m G/ n1 E7 d1 D
function hidetext(){( z4 M2 j! ?; z3 v: y5 a3 H
if (document.all)
) h3 P8 ^: y& jsupertext.style.visibility="hidden"
7 E! z2 h6 }% M1 f/ M0 U& o: telse if (document.layers)7 [3 `6 _( _9 u7 M2 j
document.supertext.visibility="hide"2 a+ E# b f% ~- G6 ~- p
clearTimeout(animatetext)% J) k! w, z( V1 a; }* b
}
- Z" z. |! k* G$ d0 r! ]6 [
. `( ` \$ t6 U$ F8 ^* aif (document.all||document.layers){$ m3 C5 j- e( O! t
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')$ d' D+ O' ]9 K/ z8 D; t) k
window.onload = initializeBall;
3 {7 w" a: ^ r2 lwindow.onresize = new Function("window.location.reload()");/ D- ?2 i! m2 N9 L/ ?% q
}
% U* h2 H* O9 N6 K: t P) S1 X b) i; {) ^
</script> |
|