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

|
网页之不断弹射的文字-特效
<style type="text/css">
" u6 k" |; q- D3 M#supertext {# h7 u9 m% ], M- e
position:absolute;4 W0 t1 q! u2 a9 R1 {
left:0;
3 o* g8 F. ^2 p ?+ P* ktop:0;
+ G9 R) H4 g$ J7 Mvisibility:hide;
2 Q: L* a p3 r% X8 L% `/ A2 d; Mvisibility:hidden; E0 z6 E" ~* h1 z1 `
}
- \, B, \& P8 W/ N/ b8 Q( U4 e</style>
& B" P% ^# ~" U4 L _6 k<script language="JavaScript1.2">- |+ V T2 N* T& ~& @
<!-- 改变下的字体的大小。颜色-->
% _, I. S5 f( H- f: {var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
7 a) B" {9 K1 I0 i7 s) j( [var hidetimer='';
& c" ^ ]3 H0 Q& B<!-- 改变下的弹跳速度-->
3 y- c% L" |# }* Gvar BallSpeed = 20;
$ h$ i: }4 K! [. Wvar contentWidth;
1 N. q4 w$ X3 N, svar contentHeight;5 A& S4 U& I, r3 V0 B+ ^0 u
var maxBallSpeed = 50;
0 Y; o8 @5 h7 f/ h9 l
7 `% {) S( [0 K* _/ A3 Q6 [
: j; e4 L/ `5 c1 Jvar xMax;0 ~' _" [, q: b! I
var yMax;
" h( w3 w! b" Y" i) n& lvar xPos = 0;6 z+ o0 k) b6 }' G" A6 p* ~6 w. @
var yPos = 0;
$ s% l* a% h1 pvar xDir = 'right';
, x' w4 M, A0 r( k! l L# ]var yDir = 'down';: k" U* N; [& |
var superballRunning = true;
; ]9 c+ u% q! Q' h( Z/ hvar tempBallSpeed;! N# S* O0 l$ l4 z7 B8 d
var currentBallSrc;
+ ]8 r. Y! w0 L3 Yvar newXDir;5 N$ b$ n) e6 c
var newYDir;' L6 u' t y" P" l0 p% e
0 y# k+ C- W/ `; V- e, \) y# J
function initializeBall() {' n6 t7 T7 P- d! y: C, F6 w+ J1 R
if (document.all) {( y5 _9 K. _2 t
xMax = document.body.clientWidth
! d7 J! T3 Z7 C l yMax = document.body.clientHeight
& l) F$ ~3 \7 Y3 W document.all("supertext").style.visibility = "visible";, Z* M. |7 ? b/ w2 Q' A' k* R5 b5 l$ \
contentWidth=supertext.offsetWidth
I I' R* J) ]9 ]% R contentHeight=supertext.offsetHeight
8 K5 B n( e& w; |3 ~& _ }7 Z( w! [5 C- V
else if (document.layers) {
7 _+ u1 W# Q$ S/ ]& p, C xMax = window.innerWidth;' t" ]0 Z! @) c
yMax = window.innerHeight;
3 l: E% [) w) {; { contentWidth=document.supertext.document.width
8 h# H& w5 K5 c7 b0 ?" |" {" o; i contentHeight=document.supertext.document.height
9 p/ ~, K$ t/ R: S- b document.layers["supertext"].visibility = "show";
" u; h1 n: X: ^1 g5 X1 C8 V }0 `4 o) |: o3 S( N0 h, }/ o% L6 ~
setTimeout('moveBall()',400);
- ~0 p' m1 \8 i- J if (hidetimer!='')5 K6 ^: h( k8 f2 |
setTimeout("hidetext()",hidetimer) V4 {0 R( u) |, a1 q* v( f
}
" a) L2 r6 t7 I( [$ j' a# D, J- K7 w
function moveBall() {! ], i+ P7 K1 Q1 o7 L* X
if (superballRunning == true) {" l" d2 B: h# E) O2 ?5 y
calculatePosition();
: F$ H: Q8 i) _$ P- ], O2 T. G if (document.all) {
$ W4 S3 |+ k/ f document.all("supertext").style.left = xPos + document.body.scrollLeft;/ R+ Z6 @) n3 R
document.all("supertext").style.top = yPos + document.body.scrollTop;2 Z# m, A1 d0 R* s- i1 ?4 {4 h
}; O& A* Z2 j: C0 H: c
else if (document.layers) {0 X6 L6 F% v2 m+ u4 B
document.layers["supertext"].left = xPos + pageXOffset;0 I0 Q% Q* W+ e. P5 e# {
document.layers["supertext"].top = yPos + pageYOffset;8 l1 z8 s2 i9 @, B) l% P1 p4 d) }7 Y
}
1 g' e2 @+ R& m" p animatetext=setTimeout('moveBall()',20);
, K5 C" t4 G9 w# W* j }% _% r" p$ A( d
}
2 f) u2 Z) R3 X" W$ w! | i% V6 a' N$ g. _* U
function calculatePosition() {7 |4 _* _2 k+ m
if (xDir == "right") {- I- x& d# E' ~9 G
if (xPos > (xMax - contentWidth - BallSpeed)) {
3 [' D& a( b$ k" R% f. k& U* e xDir = "left";6 [9 K% h( P. r& B: X" T+ Q2 {7 r
}7 W3 j' W$ f T X, f2 c' V
}/ p3 Z; P% x$ g3 R. ~2 X8 [ f
else if (xDir == "left") {
: W7 U: b' g6 @5 i" Q' X if (xPos < (0 + BallSpeed)) {
. z/ s# S0 o- h( a) D* D" N xDir = "right";& A* v0 R6 s8 V2 W
}' E2 l0 W+ m* e
}
: w8 [7 G% [4 F if (yDir == "down") { Q0 S8 |) B- K
if (yPos > (yMax - contentHeight - BallSpeed)) {
& l+ i' I7 ~4 d. ~# M0 F2 Y" t5 [4 X yDir = "up";
' ?3 u# a* U0 N- _0 E. D1 |4 T6 h9 J5 [2 A }
# }+ z8 v* ]9 W* C$ z4 d }
0 K: A; |8 H+ i) Y else if (yDir == "up") {
: T; T J% @$ J1 Y8 M if (yPos < (0 + BallSpeed)) {
W' V0 ~7 s. R D' C yDir = "down";
* C) R) W" N& S }
4 m# K% U7 U* s! i; i" Q* ]. R }( r- I G) m, v2 x J
if (xDir == "right") {
0 N' `( ~4 |9 G9 i! w" d, M3 V) g xPos = xPos + BallSpeed;/ s4 F2 r8 k6 D& Q( G* k
}
- o; y0 S. Q! y# x+ L8 `* Y else if (xDir == "left") {
* d! O7 X- @! s$ B# N xPos = xPos - BallSpeed;2 ]1 ^# w. p+ f1 E( ?" x6 x# j( ~( Z% C& a
}
+ N4 N$ R+ e8 g0 \/ J6 S else {
. l5 \" x& S2 h4 ~0 o8 O6 j xPos = xPos; k( U& Q% t) l2 ]6 w
}
; G+ j- E- Y5 n: F if (yDir == "down") {
/ N* A1 N3 n$ _- `+ U8 `6 { yPos = yPos + BallSpeed;" d A# y, f0 w! Y7 a! j
}' m) L5 D. F" y0 B0 ?
else if (yDir == "up") {+ R6 i7 l9 q8 U
yPos = yPos - BallSpeed;
4 P: s9 {- q% K6 G; ^ }
5 }* x5 u S: B) o+ C" Z else {
. u! c4 e& P- f" `4 V yPos = yPos;
# o z7 q5 t9 \- ~: { }' X! n, Q3 m- L' l
}
$ @% ?/ o. L' ]% b7 I, ?8 X2 _/ G L
% {1 T1 M l6 `3 J* n5 ^function hidetext(){* Y; U# q- @. F0 J% Q
if (document.all)7 Q* H4 s- k ?: n) Y+ `6 K2 p1 Q
supertext.style.visibility="hidden"
0 ^7 K3 t5 R- }. Z+ E/ e2 relse if (document.layers)
9 x9 v v v* {document.supertext.visibility="hide"3 Y' P; o; \9 F* t( v
clearTimeout(animatetext)! o% } Q; [8 d
}
; R, v9 [3 _# y+ o9 l! [5 M. V9 H6 J7 S9 e; p+ I: H! e
if (document.all||document.layers){* O! g9 T$ u% u5 }5 V' g3 s3 Y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 a& k+ D$ i+ ~( d: O8 U
window.onload = initializeBall;" `' i$ G- D; v3 ]+ ^
window.onresize = new Function("window.location.reload()");
# w9 q3 k3 s" x I6 o+ `}7 L8 N% H4 Q& N9 L$ [
/ i- w( Z- I, J</script> |
|