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

|
网页之不断弹射的文字-特效
<style type="text/css">6 s# ?( E7 K4 D6 m1 s" ~% w% N
#supertext {
6 M% o6 P/ J- |. G3 A" Sposition:absolute; A b! X( m+ }. e
left:0;9 P* }: U6 s. W! m0 Z |
top:0;
4 W% |; ]1 F) F) @ ]' }0 {7 _( R9 Avisibility:hide;
) r' d6 b7 m8 ^3 t/ m0 Xvisibility:hidden;
( ^6 Q; H! c- a0 E2 G: s- j; Y}
9 j+ F7 d1 y$ q8 p" y6 \2 _</style>
! H7 B$ v, u! p<script language="JavaScript1.2"> Y& s0 p( U! Y0 |* g
<!-- 改变下的字体的大小。颜色-->" J9 A8 G9 k8 m$ _2 P% F! @* C
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
# g9 E o+ R; c2 i8 A- Bvar hidetimer='';( Y& h" u+ A* J6 s/ [! e( D5 H% ^
<!-- 改变下的弹跳速度-->' N: Q( l0 F* ]: f, F; O
var BallSpeed = 20;
- \; \( A( Y4 S: _0 o3 @5 ivar contentWidth;
+ i/ U" ^& j1 H8 {var contentHeight;7 Q, p8 L8 ?0 Q
var maxBallSpeed = 50;
/ ^- T7 V, ?5 \- ? P& B/ o, f0 G+ P' c h: W) O( h0 G
7 N9 q1 O5 O. o+ g# f
var xMax;
5 V J; [& X# S# ]* g6 `. Evar yMax;! ~7 J. N! R6 c) C; f6 o2 C. n# [4 X
var xPos = 0;0 W$ ?, w$ I8 z {! W( C7 U
var yPos = 0;/ } l* d; X2 h+ F
var xDir = 'right';, \" P; b3 E' f+ I1 }2 i
var yDir = 'down';
+ H* A4 D, \" l1 R$ D5 Dvar superballRunning = true;
2 e: q# Q- @9 q4 Y; B, Evar tempBallSpeed;' X) m5 c8 E+ j3 d% d
var currentBallSrc; B2 @ C) Q9 d- Q" @' X4 p
var newXDir;# o: Q! z9 E. D. F* y) {& ]5 n
var newYDir;0 w5 S) V8 n: b8 }( _2 t5 ]7 H
8 |! F. w' C N) _) w- v: h* X2 u
function initializeBall() {( ^) a5 i3 l5 T
if (document.all) {
& ?6 b2 K# Q) _( M2 ~" X y. ~+ K } xMax = document.body.clientWidth. n# \& g' c# Y$ a
yMax = document.body.clientHeight: t% h4 q: y0 N
document.all("supertext").style.visibility = "visible";' G- O; A4 ]0 w8 a5 l3 g
contentWidth=supertext.offsetWidth( L' v. Q( A" d+ e+ f
contentHeight=supertext.offsetHeight" h0 T: {: g* g. K
}
7 K! U6 s+ A- P5 s% D& s. H else if (document.layers) {
7 o* m/ w5 J- C0 V! j% N+ m; X% `5 G xMax = window.innerWidth;6 `$ h% x, f8 o* a+ F# ?+ L
yMax = window.innerHeight;
5 Y+ q0 [8 M3 Y- s* [8 O8 w0 b* R4 ^ contentWidth=document.supertext.document.width' R& W: w! z) t, I4 v+ g
contentHeight=document.supertext.document.height
+ |# g2 U0 M' ?9 ? document.layers["supertext"].visibility = "show";
6 D( C- O$ E1 p& E/ v/ n9 @ }. _! o/ P. R5 @
setTimeout('moveBall()',400);
' p, U4 \6 {4 g% q* r3 [ if (hidetimer!='')8 x( p8 v4 J8 C5 N
setTimeout("hidetext()",hidetimer)& H7 V9 \! J( t) W5 U9 g
}
2 u( _, g2 f% p+ A& o/ k4 U& n9 c9 c- C& z4 t
function moveBall() {
: q( S1 ^ b2 a if (superballRunning == true) {
) {3 P- N7 ]$ I% [, M/ m" G calculatePosition();
& f$ B4 Q* \% y# M+ t# n2 f P if (document.all) {' @9 B$ [3 O2 e! J$ _! {
document.all("supertext").style.left = xPos + document.body.scrollLeft;; w, U% I7 e( k% H- j. l# y
document.all("supertext").style.top = yPos + document.body.scrollTop;% u2 S, ^! F* u& ^
}: J% N# z: j1 X
else if (document.layers) {; O, A2 z4 J+ z- P
document.layers["supertext"].left = xPos + pageXOffset;/ I1 {' K# D% R8 u
document.layers["supertext"].top = yPos + pageYOffset;, A' h; [# v! z# g" k
}# k! A9 j, x8 O" ^- c
animatetext=setTimeout('moveBall()',20);
( t- n- `4 q8 t }
, a* \0 E$ N& c. ^& o. e }
* Y0 R1 z1 C, l. B" h8 C$ q0 H% |7 {
function calculatePosition() {
& @3 e" }+ i2 t; u if (xDir == "right") {( _% \( G3 v- C, L
if (xPos > (xMax - contentWidth - BallSpeed)) {' d. c; x! @& }) {1 L; c
xDir = "left";
# g; Q) B$ @$ Z }) I: M0 C! n+ C k
}% L+ `+ C. B7 {. K3 `* S
else if (xDir == "left") {# R5 s# v8 t8 }0 l }/ A7 B
if (xPos < (0 + BallSpeed)) {
' b0 D+ c T7 C( R& Y* } H. P xDir = "right";
6 {# `, ]8 _3 i6 G2 G4 U }
- ^9 F4 ^; L9 D0 ]7 {; B }
% O- p9 N- R5 K if (yDir == "down") {1 _! u! v5 n) D3 C
if (yPos > (yMax - contentHeight - BallSpeed)) {- T& R* b$ e: P* S& ]3 K* p
yDir = "up";2 {/ W) ^' \3 c i& n
}1 ?9 {$ o! u/ A% Q7 e
}, A& H' R6 b4 l# k; F
else if (yDir == "up") {
. N) W4 T' W3 W0 R! `$ y1 l if (yPos < (0 + BallSpeed)) {
0 o" ~ N b0 K/ x( G yDir = "down";
4 I" c# `5 n* H2 `2 u; v }
& {# k. @; v! s7 k6 W }
4 O3 S6 Q1 G' y9 _- _5 z if (xDir == "right") {
% B7 E ?5 [+ M U% [6 I/ N& Z4 Z- V xPos = xPos + BallSpeed;
3 s' I/ j5 L1 o( y6 v }
3 S: l( }) p$ ~# ~# \8 p% h else if (xDir == "left") {. i2 U9 Y3 t. k2 B- k5 B
xPos = xPos - BallSpeed;
; X3 i8 x; ^$ h( M Z7 u }' l+ P; M2 c- G& ^% ~
else {
$ n/ ]) }, L/ [- U2 K: G xPos = xPos;
# }0 g3 K/ N" c }4 z! F T3 {7 z& C
if (yDir == "down") {
; A j0 l: M W yPos = yPos + BallSpeed;+ U& k- r3 V* C7 g, V) \4 f
}& }7 H3 A& p1 N/ h/ l. f" @
else if (yDir == "up") {/ y- K6 _4 }9 T
yPos = yPos - BallSpeed;! V) n" @' c# e. Y1 e* I* ~% c/ X: z
}
/ S. W( n( j% C+ T# @ else {# h0 q7 o) _. o+ T, d+ V
yPos = yPos;
& `5 N+ ?3 ]/ V% { }( s0 t3 V) O( A- M4 D B
}
% u8 ]7 q5 k2 X8 ~$ n$ y9 b4 h' O# U4 r* w1 w0 d- f5 J
function hidetext(){
" B3 V* C k/ T/ u* A. Sif (document.all)4 k' W6 ^5 e' S+ d- G6 \% I9 @
supertext.style.visibility="hidden"- \- A! p' O6 T- a) z! q- ]3 k
else if (document.layers)
9 V; N% K. l L! z4 Mdocument.supertext.visibility="hide"5 y' b. G- Q6 t q4 z
clearTimeout(animatetext)& {" w$ y2 ~1 A5 L) Q
}: s. j3 \8 `9 J+ V# F' q$ H
; V5 h- s v7 a; G- R7 l
if (document.all||document.layers){ u# }$ ^1 W% _( N
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>') j( `0 b2 Q" i4 @. U
window.onload = initializeBall;' O, B) f' W. ]
window.onresize = new Function("window.location.reload()");: m; Z5 R+ c6 i& a: `/ u% Y$ W1 g0 N9 J
}: v2 a4 d% U5 w* K
3 Q1 `6 X6 Y @# l$ n# s
</script> |
|