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

|
网页之不断弹射的文字-特效
<style type="text/css">
2 |) y: h9 p! P4 F# z2 }" e#supertext {
* j& P$ w- E6 ^ ?' ^. sposition:absolute;6 P* |7 U( X, o: }+ {- k2 o7 K$ u b
left:0;
+ V; ^0 k6 v5 w$ m/ `top:0;! F- g+ e; d# s+ Q8 |
visibility:hide;
0 I. j$ b% \" D# C$ hvisibility:hidden;
: _2 U; k1 }' R}
" s) F) W) k p4 s/ i" X A</style>, j% O3 |& x; T2 h; P
<script language="JavaScript1.2">, o9 v8 S7 r0 `0 h' n7 \, g% b+ L3 \
<!-- 改变下的字体的大小。颜色-->* [8 m* v( B" X% C% m; Z. F
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
* W2 Q4 R+ n4 @9 M% o, nvar hidetimer='';
( E' h i# K( e' X' j<!-- 改变下的弹跳速度-->/ S4 r8 i0 k- R4 p, c, O. y
var BallSpeed = 20;; Z# S3 o, @; |# b. o
var contentWidth;7 S& t% q* i8 i- E1 z$ a0 N
var contentHeight;
3 h) M) B# s3 U3 K' ` R3 |; Dvar maxBallSpeed = 50;
" U( {6 ]$ ?: y" s) b! p
5 Z* ]& g+ Y! @( _" _( l
5 @+ G5 H/ A2 ~1 J. t; gvar xMax;1 @, r; s Q2 R. e( S
var yMax;8 c* A( E+ ]( c0 A/ B b6 Y
var xPos = 0;
# Z0 g- Q7 X) zvar yPos = 0;
* N" Z9 y, |+ qvar xDir = 'right';
# L; U3 i5 H5 _/ |var yDir = 'down';6 q8 ^& j' r, I8 ]$ D1 b# T
var superballRunning = true;
: [' W5 c1 k; z' ^/ J/ ^5 Q+ {var tempBallSpeed;
6 t) ]& @% p; `; m3 T& Mvar currentBallSrc;
5 W8 B8 a% Q4 F$ H* s5 V1 ] wvar newXDir;+ j' G6 C; T* S0 t+ t* E
var newYDir;9 i2 S) L% h9 C; S
; v, t L+ ^0 L/ w. y2 D
function initializeBall() {
2 o$ \; v: e+ C- A5 t- `. y if (document.all) {
* Z3 l0 k0 k) ~ xMax = document.body.clientWidth* ^5 ]! |; w$ n- G) D
yMax = document.body.clientHeight
) Q" R4 o. A/ [, u- w) j document.all("supertext").style.visibility = "visible";$ b. ]- Z- C7 m0 N. h$ N
contentWidth=supertext.offsetWidth
1 a9 \/ L( x6 Y* B8 g; o contentHeight=supertext.offsetHeight
6 M; W1 Q8 M" E, N0 Z( T }" ]% v5 C+ R9 x7 O0 ]
else if (document.layers) {
3 _6 W& b1 y' x7 r$ p! l+ l- b' g n% A xMax = window.innerWidth;
8 s \: u) @+ y- j4 x6 d# F3 ~ yMax = window.innerHeight;
3 t c8 t" W1 N. y8 I% z' t& Z& z contentWidth=document.supertext.document.width C% r% s5 n! A1 e" Z, O- J
contentHeight=document.supertext.document.height! J+ m2 E/ F7 x# N) @: x
document.layers["supertext"].visibility = "show";
4 q- `; U6 @6 y }
6 Z# D5 X& r# R# ], D3 T setTimeout('moveBall()',400);
/ I! D6 b: l/ T" M% p4 ]; H) e% I if (hidetimer!='')
1 Q8 t! L9 i1 h* Q! K& D8 i q setTimeout("hidetext()",hidetimer)$ t% @+ p1 A0 y$ P9 E/ D" I
}
1 R2 ?, ~. l! u; X4 ~! d/ [4 e) m! b! B
function moveBall() {
0 |# v2 N" T# M if (superballRunning == true) {' _0 \8 _; q( Z- t: J& g+ j
calculatePosition();
, F, H0 R7 S: ]" M: X# @7 p+ a if (document.all) {
3 R9 G2 ^% s. Q' f! W document.all("supertext").style.left = xPos + document.body.scrollLeft;7 h5 @2 }- B: W7 G
document.all("supertext").style.top = yPos + document.body.scrollTop;
7 g7 c, h& L/ O, p4 l }( w! H k$ L. N8 v" ]
else if (document.layers) {
$ {: |$ k# D% Q document.layers["supertext"].left = xPos + pageXOffset;& B. q7 O* x- `
document.layers["supertext"].top = yPos + pageYOffset;
9 I( f( n( X. |5 | }
9 {) N. H: Y0 o9 i& U/ P animatetext=setTimeout('moveBall()',20);
% Q* ~' H1 U7 K/ g) |0 U }
, A$ w6 z2 K6 e8 g5 d }
+ Z# e3 J6 ]" o; q/ q( W) g, \/ u! n9 i0 [5 K
function calculatePosition() {
8 [: X n9 r# ] if (xDir == "right") {
! b3 U7 g& n- _9 x- M* z! K8 | if (xPos > (xMax - contentWidth - BallSpeed)) {8 b D; m; |9 R- x
xDir = "left";1 q. Q/ p a( w& I% D5 c
}. e5 H" N: T$ w) Q, e1 t
}( A* {+ w3 e: N; D
else if (xDir == "left") {
1 k; K- n+ n0 E7 B- O2 H, E3 r if (xPos < (0 + BallSpeed)) {% f8 H: S) a! p5 U
xDir = "right";1 z# S9 \% A, ^% S& T" }/ L4 J
}
7 X8 p7 B5 H5 {: p( P4 ]5 B }, w: Y O& j$ o3 O. ~/ }' L1 |
if (yDir == "down") {
# q+ g( R8 ~: y$ t" Q6 }5 ^8 \ if (yPos > (yMax - contentHeight - BallSpeed)) {" e! [; V) ~; L, @- p5 u1 R7 d! n
yDir = "up";
0 f/ ~+ f) b1 s; c }
( q; g/ v) w5 J1 |( H W3 _ }
' {* l$ h8 {# l" u* V; Y5 F else if (yDir == "up") {
# h! F1 J8 ~9 [1 e if (yPos < (0 + BallSpeed)) {
# ]/ g" j0 P7 ?. n# P2 K% N* o' } yDir = "down";
% h$ t2 _% C( X6 [# e! p' w }
2 h/ V% B6 ?) I- o' D. g }
5 T- V) y1 V z! L& L: v if (xDir == "right") {; P& G& ^! u! i1 _# E
xPos = xPos + BallSpeed;
: j. G! @8 `; p% Y6 X4 s }
( z2 T1 P8 t3 U) U" @6 @ else if (xDir == "left") {. ~4 ~. X+ `' d5 X' W
xPos = xPos - BallSpeed;
0 `" O% w1 R# ?/ x; Q } g( C1 D: v/ ~1 _# g2 n( j+ Q
else {& W# Y/ M8 b# x5 I( s' z- @
xPos = xPos;( {' p# E! [3 u7 x( m) R
}
' h8 ?- `: b( ?8 Z7 ~+ M# u1 j if (yDir == "down") {
K" [' O* V' T w yPos = yPos + BallSpeed;
; V( A9 E1 [8 N" x! H }
5 X/ `/ ~! E7 R else if (yDir == "up") {
. y+ I0 r4 a W( x yPos = yPos - BallSpeed;
% S' F- }& ?) H. |7 a" U& K }0 j; H; b3 Y3 r+ d% Z" m4 _5 m! n
else {; S Q) S4 k% t+ B
yPos = yPos;
2 s8 T3 O0 Y6 [6 S3 u: [5 { }
1 n, X, O: C7 F$ ]* r2 k }% D3 n$ p" }# ~
3 P: S1 G$ f6 s5 J
function hidetext(){9 r% R, z6 B1 R2 E3 T7 G
if (document.all)3 W1 Q. i$ M1 i7 l- k4 o4 T, d
supertext.style.visibility="hidden"
* h7 `, f9 R) Gelse if (document.layers)$ T& J5 U% V* c" k9 Q- _
document.supertext.visibility="hide"
0 X; B6 ?0 X, V$ D0 _' k8 J& sclearTimeout(animatetext), ~* ^/ c3 x6 Q' N3 @1 b
}
. h% Y1 A8 B ^3 N( i+ \9 Z; r% X9 s1 d6 L+ Z
if (document.all||document.layers){
o3 o# q i. v6 c6 Z: ~( Ndocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 V, k, T K# O/ m* M; t0 ^3 D A1 Q3 k
window.onload = initializeBall;
# t. m6 k+ v K( m$ A' ~window.onresize = new Function("window.location.reload()");7 M$ c' W% e2 N; s
}8 E& f. @3 x6 R+ G* `8 O1 X. [+ H! m
' E$ O* I1 P5 v3 T: z6 _. W. n
</script> |
|