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

|
网页之不断弹射的文字-特效
<style type="text/css">
" l: M3 B9 Z; ~- D#supertext {& p7 t3 f- U8 a% j
position:absolute;
8 Z- G6 i, {, t. yleft:0;+ e* O' g; o$ E; n4 s- m" D" b
top:0;
5 f: R1 ~5 q$ o5 |+ pvisibility:hide;0 _9 L& G% I3 y; d
visibility:hidden;6 U3 ]& v& J0 w* |
}- v% v) e; A/ F9 \- s
</style>/ A- L9 J8 l* m! ?8 j) H- t0 a
<script language="JavaScript1.2">
9 t \& v* o) E j) D<!-- 改变下的字体的大小。颜色-->
2 i, j- d D5 x8 Xvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>': u! L: r9 X! t$ s
var hidetimer='';
: _- z4 e' j( E! r$ n<!-- 改变下的弹跳速度-->
+ q- v) w( P xvar BallSpeed = 20;
0 k' |% J: O7 N) ?3 q* j' Hvar contentWidth;- t* ~7 [% s. |( J5 x/ T, V: X( ?
var contentHeight;1 W. @6 {- d; r, D
var maxBallSpeed = 50;& |" x1 u. e' B& I# B5 g1 X
2 G* w8 Y5 v3 y
# k8 Z, [1 E! T1 L0 a
var xMax;
, X" `) V. c$ }& ?8 `2 _var yMax;
9 ^3 o- p: m- i4 P evar xPos = 0;2 v4 P" F+ l& Y8 ~6 E6 T, n
var yPos = 0;
& h7 t3 d- E+ Y- Ovar xDir = 'right'; R! n# X$ g. C5 ]# n% A! X9 l
var yDir = 'down';
' \' t0 Y/ R D. @/ `% b4 o: vvar superballRunning = true;
( x3 d1 N# r" s! `! Gvar tempBallSpeed;
3 x7 l+ s) `4 J0 C8 t. A4 o9 e% ]% ~var currentBallSrc;0 O* Y) C. |) v1 E" `
var newXDir;9 t$ o& b* P5 F! }
var newYDir;; @9 }8 R$ J8 s! [
* I7 K3 O, X+ E9 G- F9 s& [6 {7 k: `* ffunction initializeBall() {* H0 {& F4 p0 l" I' O7 r* {$ T
if (document.all) {
" d+ M9 L; F/ r4 |7 n8 F8 K' Q' N' E xMax = document.body.clientWidth& ]/ G+ q7 \ L& d4 P
yMax = document.body.clientHeight
* t0 [+ m$ U+ b, Q5 g& Z9 `. L document.all("supertext").style.visibility = "visible";. k g( Q3 r4 K% X
contentWidth=supertext.offsetWidth' b$ N' g" Z$ Y1 N+ |
contentHeight=supertext.offsetHeight* w M: g# \' M3 P; C
}
: J# o/ e2 Y! H- t6 ^; h else if (document.layers) {
( C8 b* u% {& F/ e+ _3 J, V8 o* ~+ C xMax = window.innerWidth;
' d7 }1 w5 j0 j7 K yMax = window.innerHeight;4 ^6 d3 q+ M, R/ W- ~
contentWidth=document.supertext.document.width6 f' j$ M" F* y6 A
contentHeight=document.supertext.document.height6 M0 D& V7 r/ j, E4 d- M
document.layers["supertext"].visibility = "show";* c2 Z2 ?. K2 E( Z' s% |
}+ b$ C- g9 J: a9 U6 b; E
setTimeout('moveBall()',400);4 D# s) a0 g( w( o$ @4 Q' ]& |
if (hidetimer!='')1 I/ Q7 N% H& J6 f9 O- h/ J
setTimeout("hidetext()",hidetimer) r6 S }( R, m3 P
}
J) L0 c/ W6 ~# p: B/ R; c1 ?5 j
+ G \2 r% K9 [function moveBall() {% l* Q2 f- A/ S; T) ?" X9 t/ f
if (superballRunning == true) {
# F& X2 Z6 u6 v0 D# A H calculatePosition();
' L" o# o( U, q, b/ u, m if (document.all) {
) z& }/ i9 M4 X( o document.all("supertext").style.left = xPos + document.body.scrollLeft;
* Q) k: n/ c0 Z9 {) g: X document.all("supertext").style.top = yPos + document.body.scrollTop;5 j- O1 N8 M; [9 x$ _
}3 S& e, L' \, {3 ?7 P9 l
else if (document.layers) {6 R( A2 i( `( S" v
document.layers["supertext"].left = xPos + pageXOffset;2 M [6 P7 I3 S# S* p. K" I/ I" e
document.layers["supertext"].top = yPos + pageYOffset;4 ^. _1 f+ m( e2 e& B) |* [
}4 \! O" Z' O8 S: c$ j
animatetext=setTimeout('moveBall()',20);1 N8 k: ~' {& M; v6 f4 a
} A. i3 K/ v* @, y
}
, p" ^, E( F* k/ x
$ ?& H7 Z- N$ W+ r, w6 o7 r$ \function calculatePosition() {9 t# r/ s- ^# v. {3 @. r$ ~
if (xDir == "right") {
/ V1 z3 l; m0 `+ a if (xPos > (xMax - contentWidth - BallSpeed)) {
5 d' D1 Q3 q" L xDir = "left";
0 ]: h7 w$ e4 c }7 y" I' ?" J" t' K5 \, V
}
( j# K! A! r# L else if (xDir == "left") {
. t: p0 m% a& F; } if (xPos < (0 + BallSpeed)) {: w% g$ ?" W0 t- l$ A6 K7 i
xDir = "right";
/ M! A, C1 w( a& H3 v% [. g8 C }0 f9 i/ |' h, ]
}
* ~; S9 k+ Q% B6 c) | if (yDir == "down") {
* Q4 ~% A6 `5 h8 b, c- g! _' z$ S( H if (yPos > (yMax - contentHeight - BallSpeed)) {
: d+ F( l1 e j- }2 T7 n( M yDir = "up";4 l1 x4 v1 ~# v+ `
}- ~( C! A( L5 I2 ^* L2 x; a/ z
}
: a$ P: g% `+ j9 R1 s else if (yDir == "up") {
8 K) h- P/ C, F6 S7 E3 A& l5 g if (yPos < (0 + BallSpeed)) {6 C9 S- |: C6 a6 u; x, `
yDir = "down";6 b _9 Q. E: d. O& |/ i
}
% a( |7 ]: L* h8 W }2 U- C3 q" I ]1 H" C/ C
if (xDir == "right") {
2 m' ^0 c" G7 v1 l. U xPos = xPos + BallSpeed;/ @0 s/ h' J* m! t
}- i2 t: o) i0 @, V
else if (xDir == "left") {. s* l4 X/ V K! Q, ]- N/ f4 H2 L
xPos = xPos - BallSpeed;+ |3 O: z2 d; b# B. b
}
3 Y; q9 h% B& ^ else {
0 X2 M- X& A# _: Y8 ]& l xPos = xPos;
& ^& e8 r" b! i' l2 @ }
, [( i/ q( g% f- b; p1 P0 H if (yDir == "down") {6 g& {3 d! H9 i9 D N3 g9 n0 U% E
yPos = yPos + BallSpeed;" \; H: e- O8 c2 |$ ?4 |5 ?3 j
}
5 v: R& r7 q6 W5 j" g& x( H else if (yDir == "up") {* ?* B8 A. t/ t( G
yPos = yPos - BallSpeed;
2 t& V2 Y$ c4 u5 P; |' p) K }4 @# m9 t3 L- J. g/ R
else {5 ^ a5 ?% `: @: R
yPos = yPos;. [$ A7 V( z$ i3 S! H# E
}
+ N+ g8 x* w( R% ~2 u* S9 |) E }; k: }4 j; \, A8 O" {
v$ y$ @' \% C7 r9 f/ R8 y8 M
function hidetext(){) ]3 M- d6 O. M, e" M. E& M: P
if (document.all)0 r, t9 Q0 K1 f, N% e7 z v
supertext.style.visibility="hidden"& ]; O. ^* r+ _% O1 l
else if (document.layers)0 X7 a5 e: A2 m0 q8 I% Z
document.supertext.visibility="hide"0 f# I" N4 e* q( E
clearTimeout(animatetext)
# K# p0 }, c6 d0 i; c/ w}
% L! H+ V$ H# }2 U( X
0 c$ I% D, [; Mif (document.all||document.layers){% c% j# n- ]/ j, [9 F. p
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
% q$ c$ J' e* U" x' g. i# Swindow.onload = initializeBall;% t8 K! f! n U
window.onresize = new Function("window.location.reload()");4 t; x& Y9 h, i! q g$ ^/ f- X6 U6 y
}' b7 q1 C! r2 A5 {- v
0 E# a# u+ y. R0 x$ l
</script> |
|