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

|
网页之不断弹射的文字-特效
<style type="text/css">+ x4 B& K0 J g/ P; k
#supertext {
8 ?% u Z- Q# P$ p0 V2 gposition:absolute;
4 s( U$ _ x2 w0 G o8 aleft:0;
+ J0 O3 {9 ]( _: N' R% D; ztop:0;* R( g: r) ?5 J
visibility:hide;, U {5 Y* C( D# S y
visibility:hidden;" ]7 ?7 S7 J0 |# L0 O* S
}
: p3 X! A1 u: w" o# W- }: o- Z</style>) m$ z# C0 _5 A4 S8 y
<script language="JavaScript1.2">* m) [" z9 w8 a$ F
<!-- 改变下的字体的大小。颜色-->* m# [: `" p2 @, b" V' c
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
1 q) P% n1 n+ U$ |' _4 a5 Uvar hidetimer='';
, r) x% d' a! z# K. }. V$ a<!-- 改变下的弹跳速度-->
- {3 a" I5 z0 j/ cvar BallSpeed = 20;) m& z; @+ P$ t$ w0 c9 A
var contentWidth;
8 j+ k: A- R2 g' H) ]var contentHeight;
& G h5 Q$ M9 P( i# {* Bvar maxBallSpeed = 50;
# n2 D' g) S+ t+ \; ~( `$ I I) E Y) r# r5 L
& k/ }- Y3 Q" i6 H9 O7 I/ V
var xMax;
- j1 |8 u4 K$ C" jvar yMax;
C1 q$ t/ y+ ]9 X% B7 O' D7 pvar xPos = 0;
; e9 B) {# K! Hvar yPos = 0;4 m8 g6 a, p7 O2 }
var xDir = 'right';0 y+ @& X4 P, W# o4 ]# W% S
var yDir = 'down';
4 k- ^, y: _% v4 N+ C2 p& uvar superballRunning = true;
6 ~( k: m8 o k2 pvar tempBallSpeed;
' Y( V" V. k. Lvar currentBallSrc;
' R! a* n4 }- V4 \: r: D4 J+ d+ \var newXDir;8 Q5 J% R8 }5 w& g- d2 q6 h0 o9 u+ T
var newYDir;
! g# ]% s6 V& Z p6 M
0 g% M/ d- H5 j( G! m3 ?function initializeBall() {
7 [ B Q4 F6 _/ |2 W8 W7 j if (document.all) {
/ S, K+ Q% k8 `! D7 m& x4 y xMax = document.body.clientWidth
; u$ K/ ]4 _# u( A yMax = document.body.clientHeight% [: S$ w- H4 h1 C7 y3 h8 |
document.all("supertext").style.visibility = "visible";
6 n6 G2 y7 _! }, s9 O, s contentWidth=supertext.offsetWidth( x1 e, y$ b6 B- ]
contentHeight=supertext.offsetHeight
$ ~7 H+ K( S4 V. L) c& t& w1 W6 u }2 |: O0 v) i# C0 e
else if (document.layers) {. u3 d4 v! R: g# M) w
xMax = window.innerWidth;
r8 ^; A! o$ A) ]9 E3 D: F yMax = window.innerHeight;
( J1 q0 |5 q4 G2 T contentWidth=document.supertext.document.width( x! k* a6 X$ U0 y( X/ O
contentHeight=document.supertext.document.height6 I- ^4 H) w! p v- j( x6 C. p* c5 O
document.layers["supertext"].visibility = "show";
. v2 E- f4 P& j9 x }
Q l. }) u {6 P8 n) Y setTimeout('moveBall()',400);
1 \$ d8 @- g/ c0 h if (hidetimer!='')
0 ]& b8 ]0 q& o) S7 V2 n setTimeout("hidetext()",hidetimer)
" W( K1 h6 ~; H2 } }& [" ?4 _: H7 `3 h6 P( P
% \0 h+ t, g4 h L7 X5 I3 r
function moveBall() {
4 b2 l+ k4 w" D0 g: F: M! Y/ k" c if (superballRunning == true) {
7 R2 z+ T* N! O9 U' Y calculatePosition();
+ k+ m+ W# [! C6 _7 {$ ], e3 Z if (document.all) {
0 B* ^2 k4 [/ I3 r document.all("supertext").style.left = xPos + document.body.scrollLeft;* o% x) Q2 `! G/ D7 T1 L% B
document.all("supertext").style.top = yPos + document.body.scrollTop;
" ?9 v" {$ o& G( a1 T }
5 B. B1 v/ D! J& J7 V- T( h else if (document.layers) { p8 k; d9 N+ h/ H$ m% { F
document.layers["supertext"].left = xPos + pageXOffset;
$ M# S1 U5 a4 ] document.layers["supertext"].top = yPos + pageYOffset;
8 g0 x4 B# h: |, j* k; [ }
}# S4 v: W t/ ~# Z animatetext=setTimeout('moveBall()',20);5 L' X' n/ ~. f
}
6 B. D* l0 g1 h; U N4 Q: L" f }! _( _4 C1 m. |7 N
- n1 o3 e- p. {
function calculatePosition() {8 Y) [. w$ E, ~; ?
if (xDir == "right") {( n9 X6 t+ }7 ^& J6 K# m# k
if (xPos > (xMax - contentWidth - BallSpeed)) {
5 |$ h) n# n4 z# \: Z9 ` xDir = "left";/ p( w+ E8 M& J4 z4 Z' `* L8 f+ w
}
* L" g) L9 b9 f- E% }4 H }
" U" b: A& B$ w6 \* j: W) g9 ~ else if (xDir == "left") {- D0 S8 }. l* P& w: X2 k
if (xPos < (0 + BallSpeed)) {
. @$ k/ x# I2 f, B3 s4 E xDir = "right";) j9 ?% K& `9 i' R
}
- `: N) \. \6 r7 N+ Z8 S }
0 p& W0 O: e4 n/ N$ A if (yDir == "down") {
) J: t$ W9 N* o2 X' K0 r if (yPos > (yMax - contentHeight - BallSpeed)) {
l; @7 l1 {1 l, Z. Y, Y yDir = "up";
, W4 B8 t1 Y. g6 b$ h }4 g6 i& M: N4 J& k5 [
}/ S0 B( Y/ ?( ?2 l: m
else if (yDir == "up") {4 y9 _2 Z1 W7 u3 C/ y/ ?
if (yPos < (0 + BallSpeed)) {
4 _; Q# m/ s0 g; v* G J+ q- v yDir = "down";/ `1 s2 Z* ]& h
}
! z$ V/ ^( L( P) O }3 |& P# S" o7 U: y; O% I
if (xDir == "right") {
5 M( b" r |" ~7 h+ L xPos = xPos + BallSpeed;* m, s4 B( Z1 a" K( t
}5 E3 y" V+ `: k: \; F1 I
else if (xDir == "left") {' f7 z8 a- V; r
xPos = xPos - BallSpeed;) k! n2 h6 f1 l# s! [ u( l2 \# O
}
9 ^, c/ f+ e% v: Q: \ else {. |! c8 o6 R. ~& {3 H. y! W2 a
xPos = xPos;$ U/ Q& z1 Z& Y% l2 s# J! k. p
}: N( T( }+ E: E/ ~- G8 H
if (yDir == "down") { A7 K) U/ g9 p+ t/ @
yPos = yPos + BallSpeed;, w0 R2 p7 L, [. G: k
}0 M& o& M. F+ X1 O" ^3 B, L! N* N
else if (yDir == "up") {
+ x: p) o/ g) ]6 M yPos = yPos - BallSpeed;
* Z% A% S; {6 S$ i }
u+ q3 A l9 r, f' L. m else {
% ^7 [* ?5 q7 z2 ~ yPos = yPos;
# U- t$ Z. {0 w8 I }
7 [: U# a3 D" p, H! B9 O }
4 U" S1 \, u, m5 Y' s1 L- y
: a7 L/ @/ U Z* j# jfunction hidetext(){
1 l! r% W4 l5 F2 i1 |if (document.all)
7 _' u. e( i# C$ @1 D% ?9 Asupertext.style.visibility="hidden"
4 N1 n3 q; B- l. f( V+ [+ `$ eelse if (document.layers)6 d* w+ N5 L* S( ^# V6 g6 U8 L
document.supertext.visibility="hide"1 O* h6 L# o' B! u; A8 j9 o
clearTimeout(animatetext)1 U( P+ W: m- x- J' y# O+ O9 A! W
}2 s8 Q5 ^8 h4 `4 r9 P1 W9 }; [
- j) h. Q9 F1 a" d6 |if (document.all||document.layers){
8 x2 \* [; Z1 u8 }# F. _3 Jdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')3 _8 J# c# f5 N; e1 ~
window.onload = initializeBall;
6 y/ {8 B5 @- V. s/ t: h2 n3 x/ Lwindow.onresize = new Function("window.location.reload()");
( @3 i$ R R2 i) K( G& c {5 D}0 P4 D( o8 o# P3 F; [: |" \( Y+ Y( q+ I
! L9 {* b% F, I
</script> |
|