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

|
网页之不断弹射的文字-特效
<style type="text/css">
2 P- S+ q+ \7 W' _4 |#supertext {
, w( f u# f2 I2 a, Dposition:absolute;
/ `$ R& i" ]) k. l+ Z+ X0 {# n: Cleft:0;
9 H1 e) e9 `, atop:0;
" y! l3 @6 o% I9 ~5 L* w' zvisibility:hide;
* X, ]. s2 U2 g0 G/ [visibility:hidden;6 @& I* I+ r6 W( o& i
}& }, q" g" ~ \) l% |: i
</style>' [/ q; ~. J- w; K, l9 N& U3 t
<script language="JavaScript1.2">. ]8 |3 C" \$ i
<!-- 改变下的字体的大小。颜色-->
S/ c$ ~) X7 Y+ hvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'" { b! f1 d4 @' t+ d
var hidetimer='';
% ?: Z; j! g: p/ q- @1 Z<!-- 改变下的弹跳速度-->4 z3 s$ L2 `, g, }5 P4 b5 d% O
var BallSpeed = 20;( B7 U9 o! r8 I( o# L% ?
var contentWidth;
0 y: P" N! {2 |$ ovar contentHeight;
' H. U' t9 j* E8 n2 R, fvar maxBallSpeed = 50;" L5 i0 o+ P% N3 H) P% s
$ J9 N- @% v. w$ F7 r! j
$ c$ l* `+ g% |! F1 X; x7 V! I; nvar xMax;
& g; t& \9 T. n: c" q' S- gvar yMax;
7 F0 ~0 r# j' G6 b! V% Y0 K) K8 Wvar xPos = 0;
6 ?( f& b* t, cvar yPos = 0;
& f- b6 p3 `; w/ e' b0 ]& J. m& _var xDir = 'right';5 W% a" r5 ]5 n% Y) H/ h. B
var yDir = 'down';
; [8 v5 R- i0 z9 W1 i3 Gvar superballRunning = true;
% i9 u9 p {3 ?1 S" Ivar tempBallSpeed;/ o2 r* ?4 b* C$ j- ]
var currentBallSrc;) ?7 H8 X( b( C+ W
var newXDir;3 a; y4 T: P: r* n# K1 r( ?
var newYDir;
, G- F, L3 B+ j, C' n% }: k! N" r6 o1 k- l
function initializeBall() {: G. |; S' I% \, z
if (document.all) {9 h1 Y8 J- Y2 |
xMax = document.body.clientWidth7 I$ ^7 h, v0 }5 q ?, F
yMax = document.body.clientHeight
. M, r' B3 X( A" t0 I' X, { document.all("supertext").style.visibility = "visible";
5 K/ v2 [/ Y: q contentWidth=supertext.offsetWidth9 Q0 U% j/ m& l) U5 W4 |$ G3 U9 E: m
contentHeight=supertext.offsetHeight
; S! c" C4 `; P2 q: |+ g' b# E/ ] }7 ^& S- ~% g8 q7 x, s* j* p
else if (document.layers) {1 c, z! p. A, @
xMax = window.innerWidth;& M; b) ^" g. Z8 `' u7 d4 M! b
yMax = window.innerHeight;
5 z. k" h" E! O contentWidth=document.supertext.document.width: n+ }) Y% r# R0 M
contentHeight=document.supertext.document.height: H; i1 b: @# c( ^
document.layers["supertext"].visibility = "show";6 n$ }# _; Y1 p, z5 u
}! F m' H+ q8 `* w% V. `
setTimeout('moveBall()',400);
6 s6 m) r2 w9 z% O- U if (hidetimer!='')
5 s* t5 i( c' @ setTimeout("hidetext()",hidetimer)
' R% R5 o' c! p }
3 F& B0 l2 V' l0 g' ?8 q3 p, U( o3 h& e- j% ~3 j
function moveBall() {' _% @. \0 a) k# V, l! W8 N: _
if (superballRunning == true) {/ g' w9 P/ L! h! C8 T3 P w8 A
calculatePosition();
9 O0 h( N4 X9 ?0 X* S6 i0 y. @! M if (document.all) {6 N" \6 ]. @9 o5 v- \. A* j0 y3 e
document.all("supertext").style.left = xPos + document.body.scrollLeft;- H) V+ Z! u" q3 w3 `" y. r8 o
document.all("supertext").style.top = yPos + document.body.scrollTop;
; s# Y# d* h8 W x" r$ ^ }
C1 o' L. V& m& r8 ]2 h+ L. y else if (document.layers) {
6 h' v5 L+ }3 L E q' e- s document.layers["supertext"].left = xPos + pageXOffset;4 }5 C% ~3 u: R$ T' _$ L( J
document.layers["supertext"].top = yPos + pageYOffset;
( d: f d' C) P S! O }& @) P7 D6 L" Z5 a# [5 W4 X
animatetext=setTimeout('moveBall()',20);
6 [- U" f( `8 ? }
@) V( Q% `$ ^; R }! k; l ` `6 ]
% b: k' [! Y) U* J2 [! J" M
function calculatePosition() {
/ [4 ?0 C8 t* z" S, z; k2 X if (xDir == "right") {9 [2 W; @# H1 L( C
if (xPos > (xMax - contentWidth - BallSpeed)) {
# \( {* ?- V. n0 U# F9 Y xDir = "left";
. Q" d; ]4 \* ^ }! f6 s, \- @% ]% G* q8 M
}
9 D" X4 d+ J; z5 ] else if (xDir == "left") {
- f& h, ?0 U6 D* ]1 i/ N1 C if (xPos < (0 + BallSpeed)) {2 v3 e x$ R8 K
xDir = "right";% L* P- _( n$ K3 y) @) Z% Z
}5 ^* p$ W; E0 P) r& b: u$ K
}4 A. f0 E d! s! S
if (yDir == "down") {
8 U; J7 \+ H g# O5 @4 U6 `. P if (yPos > (yMax - contentHeight - BallSpeed)) {
5 i0 ^/ z6 m' }8 i, M g yDir = "up";
2 }, L8 Z- c& f }
& h; p( D5 H/ _ N. Y }4 g- x+ f6 {% n
else if (yDir == "up") {
7 d( B$ c! E- W9 G if (yPos < (0 + BallSpeed)) { Y% y; b* f; V- c# f1 Z' ]8 O
yDir = "down";9 v1 y$ C9 _2 i W% F
}
3 V. P( p' u0 a4 A. D2 J# H }
5 b! T6 S, F9 w$ c! X( o if (xDir == "right") {+ v2 }- J) e5 a; K' }/ P7 C) b
xPos = xPos + BallSpeed;
$ k) R+ O* Q( \3 G$ @. I' O }
4 }& D! z% m( g- y else if (xDir == "left") {
; R$ E# j: |' @ xPos = xPos - BallSpeed;
L, V7 n) d1 K) \, C9 v! s( W! k# a }) s7 w9 ^ |; i" ?
else {
' g' W" Y. c' i' |" o! F' c! {# m xPos = xPos;
. _# {& [& X* o5 `, ^ }7 Y' u; S- o8 |" L
if (yDir == "down") {% Q0 m8 q% o* `$ L# g" u! W5 A
yPos = yPos + BallSpeed;- ~7 } ? l9 ]7 M0 f8 q
}) l( S% L" \. n/ F
else if (yDir == "up") {
: }& L+ W8 y1 W! }+ t# B yPos = yPos - BallSpeed;- A* J* M) l7 \. U# E& g
}0 i X5 o5 u# X; T
else {* o. G; b. U* @$ O4 |: j
yPos = yPos;- l, o6 h7 N. w+ l; S
}
- c% P. A- X' } }- v, v g$ B% x
4 |7 t2 k% T' K* {function hidetext(){; e' Y9 o. u, j
if (document.all)
$ X9 Q+ c6 {7 m" Hsupertext.style.visibility="hidden"
. \/ V- D( }& i$ welse if (document.layers)* D/ ?# ^7 [$ F5 C, ~# V
document.supertext.visibility="hide"4 r% _4 F& w6 f! ^' b) o* T# {; i
clearTimeout(animatetext)
: p/ }( |, d+ k7 D" \( T3 e}! _9 ?5 i/ P: E
5 j! X* V1 s, }: ^
if (document.all||document.layers){% S# a) p( B/ F( z4 J# L3 d* Z
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
3 Z3 O2 q0 R7 c" L+ m6 r3 K. Vwindow.onload = initializeBall;% |2 F! d7 \" p4 A$ N, ?- Y4 o
window.onresize = new Function("window.location.reload()");1 w) f( y7 W1 j$ ^, Q
}
8 i8 d' ^) q5 m: `* b) p4 X! W
6 D- O m' b0 n1 D- v6 H% N</script> |
|