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

|
网页之不断弹射的文字-特效
<style type="text/css">/ I0 v5 h9 t$ p- V) u$ g
#supertext {$ k& g$ Y# K& L& k/ r" i/ c
position:absolute;2 Q! k; [' L! }5 W) v6 G/ {
left:0;' [0 K% ^, e! E8 A2 p
top:0;
, |/ H1 ]6 X5 ^visibility:hide;. r. q9 W9 N9 c1 @& \2 v/ D! B
visibility:hidden;& W# g" M6 I8 c3 [
}
W& W5 d5 `( ^& {. L; g, J. r1 ^</style>, U) y/ m# c8 f5 Z
<script language="JavaScript1.2">' o# l% G3 m8 _0 R$ ]/ |
<!-- 改变下的字体的大小。颜色-->
' M# ]5 T) z4 |9 Qvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'& g4 @* l. S) g. m$ k+ _
var hidetimer='';
+ x, q6 Q" t. Z; _$ T- o<!-- 改变下的弹跳速度-->
* e- U/ J `3 u0 Z( |var BallSpeed = 20;5 p* t! o% X3 _. z' A* Q( o0 A7 F$ c
var contentWidth;6 _7 u8 X v3 V* b' M
var contentHeight;
2 f2 d5 P7 o/ |& q- yvar maxBallSpeed = 50;
' b* A! m0 Z2 T- e5 w9 B# o% r- K6 ?5 E* l2 V$ ?% ]4 ?6 b9 `
) p. U0 m2 u% u" t8 ~1 t; ivar xMax;
7 E0 n2 h' f5 d- B, L) B# x9 I9 Kvar yMax;
7 R9 V4 a1 J. u7 d; o; U- fvar xPos = 0;) G, a0 Y- L& Z0 d) L. ^& I
var yPos = 0;
) n* o8 ]7 P. O( wvar xDir = 'right';$ `0 r; M/ z. u: A1 F8 R+ ]& l
var yDir = 'down';- D' I+ |. m9 C( F
var superballRunning = true;: t% t% b; L0 I1 Y( t" g
var tempBallSpeed;
/ h5 \% R$ w9 O& Hvar currentBallSrc;$ L7 e& \: d: z" Q- f
var newXDir;
" Q4 ?' \4 w: U. x, c/ Nvar newYDir;
. b2 ?/ y7 ?6 V: G* F
8 ^: D- v) `8 _6 wfunction initializeBall() {
% v) S a- F+ {$ P4 @+ Q if (document.all) {0 x* j' C; @. X: I
xMax = document.body.clientWidth5 N6 S$ K! F# E& S# M4 I; P0 d- b: h& O
yMax = document.body.clientHeight
4 z6 c) d6 K( U1 _9 M document.all("supertext").style.visibility = "visible";' o1 T; t$ g: i, g/ A& Z% J/ K
contentWidth=supertext.offsetWidth1 d' O4 q* b* \$ _) C
contentHeight=supertext.offsetHeight
, E, ^+ i5 H8 I* J }5 t" L3 \2 t; ~; G! c% m% \
else if (document.layers) {. E5 q& O ^3 r- G! c) I
xMax = window.innerWidth;
, k! `; a+ N1 R2 W yMax = window.innerHeight;+ F' Q: @( D1 Y: |
contentWidth=document.supertext.document.width
, T" J% x7 I: z3 ~7 O contentHeight=document.supertext.document.height
9 t! ?- j/ x. S8 Z( s document.layers["supertext"].visibility = "show";
* o) c+ U( f8 m2 y- R% p( { }
B, d% A. P! W1 }3 h setTimeout('moveBall()',400);
8 u. l8 J' C* H M$ A a8 [ if (hidetimer!='')2 i. ~0 P* Q% L4 O& s1 q9 X# Z
setTimeout("hidetext()",hidetimer)
! {- p) s1 S) \7 t7 x: ` }' R- L4 n/ a1 t3 O& e
& q2 U4 v$ r0 M, s- J* U; v- Xfunction moveBall() {
8 S% J3 C4 R1 @' u# O8 ^ if (superballRunning == true) {
' S* L' _; o+ h- }# q calculatePosition();
& ?. d/ g9 G2 x u if (document.all) {
$ E/ L4 l& N. Y document.all("supertext").style.left = xPos + document.body.scrollLeft;
* C k% B4 a: V& ~ document.all("supertext").style.top = yPos + document.body.scrollTop;7 f. d8 w/ M' M: E8 F# h# L4 d3 a7 a
}1 a# M0 d3 ]# n7 A+ p
else if (document.layers) {, d1 h; r, Y! O" c0 }, \6 g# h A' u
document.layers["supertext"].left = xPos + pageXOffset;
/ V, B1 d3 k" R7 _) C document.layers["supertext"].top = yPos + pageYOffset;0 J V3 y! ^! `, ]2 ?
}3 I$ d! t/ _& y3 ]+ Z, ]& A
animatetext=setTimeout('moveBall()',20);
% r$ l: e; Y" g0 E }
3 o% H% c4 n/ D" S }
/ O4 u% y7 F/ g5 L" N& V0 J6 }& M# H$ }! s8 M
function calculatePosition() {* a2 i/ o" g$ u' ^# m0 ^
if (xDir == "right") {. m; h6 [8 E: w+ a" q' v
if (xPos > (xMax - contentWidth - BallSpeed)) {
# X0 J8 Y! s2 |3 |; v. \. E xDir = "left";
! `/ z) p8 R* E# |6 p2 ] }
2 q* U$ R9 p- T: Q/ Z }; w, U2 w" o1 G/ u0 ]6 F4 O( B* M
else if (xDir == "left") {
6 y; }* N5 m& D! w. X( O if (xPos < (0 + BallSpeed)) {
0 D: w- e# z) i3 i1 J xDir = "right";
% l+ c* R/ n6 O2 z6 b }
X3 ?& P$ K$ k7 L }
- d& L! B2 V0 i" o if (yDir == "down") {
, K5 g( L6 u& [) F" T% G if (yPos > (yMax - contentHeight - BallSpeed)) {5 J: i* t# G% X1 D: Q( i" w4 J
yDir = "up";
T9 ^( }) N9 \) I }. b5 E2 m# `# {% x4 [2 y/ i
}
- f, ?' j% q; G* ^7 h else if (yDir == "up") {
# O% T) y! s# i- w: J if (yPos < (0 + BallSpeed)) {, H( j$ L: a& H/ y% |
yDir = "down";- H* s, Q; q& {
}
# Y# I8 d' V2 x* T8 n2 S" v6 K }
! j+ T% C3 e2 l" z$ \" K if (xDir == "right") {; H. m& G, A; i- J* I
xPos = xPos + BallSpeed;
5 S& ^" E8 {1 A7 V }* I7 z6 k5 H$ Q6 A- ]* x1 w
else if (xDir == "left") {
1 r4 e+ X4 M4 U h- { xPos = xPos - BallSpeed;
( I3 h( u, s& Z d a6 ?0 K }
, \- ?4 B. [ k* v. U% W+ ] else {% l* m! X- F( @/ {- l
xPos = xPos;$ v2 u) T8 q# ~- `! b# n( R2 a
}
* R; y, L: f. Q" _* Q5 x if (yDir == "down") {" T( [! j+ @; Y" M4 J
yPos = yPos + BallSpeed;- O: F5 l/ |" |' ?4 Y5 O" O5 r
}
" E U @/ ?8 r5 N4 H8 {& ] else if (yDir == "up") {5 s/ }* D( I$ y4 ]2 r( J2 d
yPos = yPos - BallSpeed;
& U5 B. h; T; P$ x+ }5 l3 L5 p }8 \1 x( \2 P: ]. J5 G4 n
else {
, V) j- w6 {# d+ q) }& { yPos = yPos;
3 X0 C: X: `9 {# Z: Y }
. D* z& H# l5 H1 m }% O* S+ W: | G4 R" u7 y* V
4 U S; U3 Z: ~; q, U
function hidetext(){
/ ]# T+ V& H L/ Sif (document.all)0 S( M6 _1 ~6 v8 \/ V, X/ r
supertext.style.visibility="hidden"
+ ]! x9 ], \: d. J: Celse if (document.layers)
' v9 {. Q) i; M* f6 cdocument.supertext.visibility="hide"6 b! o& Q" v: A* P8 {0 Z
clearTimeout(animatetext)
, J: F$ o D/ u}' ]# ~& O6 W9 p$ u
8 E9 n1 {! x( g9 W% B
if (document.all||document.layers){/ ]% F4 F) v& o$ b3 L) o3 m4 h
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; Z" ^( @1 I& h* swindow.onload = initializeBall;
9 M" C0 L- |$ Ywindow.onresize = new Function("window.location.reload()");
- U$ o* b/ ^5 r9 t, U2 Q/ P}
/ C& v! u3 [7 g1 X8 M0 M3 u0 n5 l5 ]- Q1 g
</script> |
|