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

|
网页之不断弹射的文字-特效
<style type="text/css">
4 Q: _8 ?* H% y6 a! r- I0 f#supertext {$ E7 \- n% {9 U% |. Z. v4 r
position:absolute;; r' S8 {0 W4 L: g& _# Y# {' x
left:0;9 _1 @' V0 U8 H' B7 ]6 w
top:0;" \8 l( {( q# R( j- a6 B) @
visibility:hide;+ f3 t5 L* S @, F# Z( _' @* d
visibility:hidden; ?. e6 C G4 `. K/ t
}& N5 p0 e0 ?/ w2 E# [0 z P
</style>) r' E8 U+ I" i) O n# i; Q$ h# ~
<script language="JavaScript1.2">
9 u) b! t7 {0 i" u9 ~<!-- 改变下的字体的大小。颜色-->
! ?7 M( Y0 O9 [. t0 X4 _+ e2 fvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
, S2 t# W6 ]9 H" b% wvar hidetimer='';
2 D9 T$ @; F* T3 G<!-- 改变下的弹跳速度-->
8 j, e5 C9 o/ _2 p3 Pvar BallSpeed = 20;9 ?: ` c/ e+ A& `0 c# N
var contentWidth;
$ @3 {' p# E K0 Q# kvar contentHeight;
* ?4 s0 ~1 D6 D8 zvar maxBallSpeed = 50;. J7 T2 A, u; y) p
5 A5 o5 `, G$ L% l7 @: V1 p
4 q. v6 C& f& d6 r% Q6 d1 ~var xMax;
2 m/ M, x j) |; Wvar yMax;1 W$ D: Q g3 z; O5 h
var xPos = 0;
; C- _& i% n! }. y, H3 @" yvar yPos = 0;
; m2 n. k" C$ X( U% Y3 Hvar xDir = 'right';
2 | A7 I' I% pvar yDir = 'down';" |" S5 s" }5 j; V; j4 z Z
var superballRunning = true;
+ A& v* F. E0 V3 Dvar tempBallSpeed;5 @- @2 J1 e) K& u+ V3 j0 D5 X
var currentBallSrc;
5 g* p H, @, w, p bvar newXDir;
/ q9 C+ r) ~4 p- R/ p9 V* L! wvar newYDir;
4 p( D7 _& J' Q7 M( E4 Z# H0 e+ G3 Z* m# e5 Z* m9 v7 o7 \
function initializeBall() {7 [% h# n2 d9 [, m9 b$ y
if (document.all) {9 C+ ~% x+ N I4 P
xMax = document.body.clientWidth
- s- g4 F$ k# L$ W, n! i" N( m yMax = document.body.clientHeight
6 t8 m" M0 t( d4 K document.all("supertext").style.visibility = "visible";- T, }7 w2 f$ @1 Q; Q1 _' h
contentWidth=supertext.offsetWidth
2 g) k+ n: Y. A0 T! C% [/ {0 w9 [ contentHeight=supertext.offsetHeight
& I$ X* k) ^7 L% i }
% ^3 I- R" Z t- c# f$ y0 h' b else if (document.layers) {
) d1 |' B- S. X. V+ b$ ?/ K xMax = window.innerWidth;
* a4 @) d! C# T yMax = window.innerHeight;" [) Y' A* H. K3 S
contentWidth=document.supertext.document.width
: M4 y" C# u* B4 @6 H contentHeight=document.supertext.document.height
! W4 Y, d7 \& e1 I' X document.layers["supertext"].visibility = "show";1 B: M8 ]$ J8 z( P' H; v ]; G
}
! G( Z7 [, c$ }: Y0 x setTimeout('moveBall()',400);# m* A3 Z0 r$ n3 ^
if (hidetimer!='')4 B) A/ {, T, e, }
setTimeout("hidetext()",hidetimer)
: N8 v% u ~6 V0 E1 U }
6 X+ G Q7 j4 n
9 J$ d, d6 K# ?! [) ^function moveBall() {
3 B* k' B! U; }* j if (superballRunning == true) {7 V- }* |0 g7 Z" {) ~" _
calculatePosition();; m9 G. [: e3 e; X
if (document.all) {: u- d! _8 |& P- m& L" C
document.all("supertext").style.left = xPos + document.body.scrollLeft;1 Q" k. m k; Y8 J T% \
document.all("supertext").style.top = yPos + document.body.scrollTop;/ C$ \8 |& {/ F# ~2 T
}
1 b; z, \6 T& G. `6 H7 Y5 v0 @) p! E) W else if (document.layers) {% A7 W" u& ?' ~, @0 G1 B/ F$ q* d
document.layers["supertext"].left = xPos + pageXOffset;" Y4 m% x3 ?9 b9 U% Y% T9 _
document.layers["supertext"].top = yPos + pageYOffset;- x/ X1 _! @! ?* X8 c* F9 z" E
}) |* V) u7 x: v# I' \0 w8 J# }
animatetext=setTimeout('moveBall()',20);
i6 D; Q8 o$ j7 H, Z2 h }: x* I& z$ B& O5 z5 r5 {+ O
}- v$ j# S3 s. @6 S1 p1 C4 \
! \2 o0 h8 v9 h9 c
function calculatePosition() {( `: Y% _* d; _7 C+ i8 g+ `/ o
if (xDir == "right") {
* e& W5 F% R$ `( b if (xPos > (xMax - contentWidth - BallSpeed)) {. ]. Y5 D8 X3 I: J
xDir = "left";
x1 \( s& i/ T }5 m! b! {) j( m, k
}: h" _6 e p+ T
else if (xDir == "left") {
8 f( }$ v8 i3 i# Q if (xPos < (0 + BallSpeed)) {# P7 I: c/ o* w8 {+ f: P7 }! C
xDir = "right";
8 u. N# t+ k5 K- g }% |8 G: A+ y, p# h
}
# \1 T2 _! P" | if (yDir == "down") {9 ]' i5 Q5 L7 l' H; F$ O5 w9 a
if (yPos > (yMax - contentHeight - BallSpeed)) {
, S7 ], g, K% r7 @2 b* B yDir = "up";
1 |; \* H, r/ ]1 l }
: Y w; |# N A5 }0 B! r }
9 X' J4 r; f, O c6 S$ O4 q else if (yDir == "up") {
8 G k6 Z" @% f. w8 E" D4 ^ if (yPos < (0 + BallSpeed)) {
q$ X0 e$ G0 Z$ ]* H+ \: A% C yDir = "down";3 t5 L4 r9 T. r# S4 J
}+ j4 u1 _2 Q ^1 H
}" G" f4 ?4 U1 H* u5 H5 i S
if (xDir == "right") {
8 p' C q; H1 O" E+ a% X Y xPos = xPos + BallSpeed;6 Z* B: S! h% @
}$ {7 ^: ], D% d8 `7 l; i$ ]' E/ f; u0 e8 E
else if (xDir == "left") {5 L1 I2 L% ~+ i9 M) s
xPos = xPos - BallSpeed;
3 ~$ K( C6 O5 u- D! ? }7 D* Y# Z. W& @$ p+ b& b% [
else {; C4 b& W' a+ V3 b6 n/ d' I4 W' D
xPos = xPos;
5 z2 W) X \! K* \% e) }7 J" S5 F }) ~0 p5 ]9 e: _: h$ n
if (yDir == "down") {
8 X' p5 D, r" r6 O- V yPos = yPos + BallSpeed;
[0 Q: D* g1 q0 S' i% s }
; A( Z9 ~3 `* }" ~# o else if (yDir == "up") {
6 b/ o( p$ N: k+ T2 p# h( ~ yPos = yPos - BallSpeed;
C7 ^7 P8 `3 F- j }8 A0 N8 W4 e* H7 k
else {( j9 z4 T: ]+ F; O2 t. R$ M
yPos = yPos;
' r4 u- V* F' v8 `6 T* q8 } }
8 w6 W2 w* H8 p! g! X5 }" _- M }
: x6 ~( p4 h/ G1 r8 I) H8 A
4 ]# I" ^; [; L! {$ ]function hidetext(){
, B/ s4 `- {# u M+ z, [if (document.all); _( X) N% B$ S* g$ V) m
supertext.style.visibility="hidden" _4 C6 l: R2 t$ _4 k6 u+ s8 C- [
else if (document.layers)5 o- \( p6 V. }3 m Y
document.supertext.visibility="hide"
% \8 z( H ^- [% w- \$ F' Z! lclearTimeout(animatetext)
0 @ Z) j/ `$ c& I! R}
% ]7 ~. \/ I4 l5 k4 W! {" P
, A' h1 `$ Z) \! E( w+ F4 n" A1 y8 zif (document.all||document.layers){. ]9 v7 }. V5 x2 |' ~' u! h p4 G
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')3 u8 T# C# y" r- m# z* R
window.onload = initializeBall;5 M% Z9 o7 H8 i p
window.onresize = new Function("window.location.reload()");
7 o4 i' f4 s5 u, Y+ R/ a}$ g* m( M) Y5 _
0 I% y' H$ P' ~</script> |
|