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

|
网页之不断弹射的文字-特效
<style type="text/css">
0 N, d2 i' }+ `& O! R#supertext {) N5 j x! C, s. l$ N; y1 n) n
position:absolute;
& I! M) Q- O6 f: Y2 |" N4 nleft:0;
% [5 D) y( y, Ftop:0;) W- C% {4 l3 G; c/ \5 T
visibility:hide;# h! Y1 o* {( z" j' N& Y# j! a
visibility:hidden;
! h* i! Z& Q) q}
# B7 b) X/ n) @- w/ e( x</style>& |; N( l4 [+ Z# f9 n. T
<script language="JavaScript1.2">1 m. [5 |9 Z3 r6 U$ z* i
<!-- 改变下的字体的大小。颜色-->
+ L: M- I0 y% r' ^var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 T' [5 O0 I# Y: S. Jvar hidetimer='';
9 B( W6 H7 a6 m( a; d<!-- 改变下的弹跳速度-->
" K5 t0 x; i6 w) g9 Evar BallSpeed = 20;' t: M1 h/ Z6 ?% I# K
var contentWidth;* v6 ?0 O( V8 c+ i
var contentHeight;6 \2 S$ W* |' ]3 Q% H0 E
var maxBallSpeed = 50;
8 X0 `3 G$ l+ |/ x0 Z+ ~1 D5 y
( x0 i& J* v$ x( _2 I! K+ bvar xMax;7 c$ b' G9 ?; E3 Q! o% E
var yMax;
; k) Y6 ~* e- ^# V: Yvar xPos = 0;
% _# ~3 c$ C# W2 h8 @var yPos = 0;$ X0 P% V: @0 R, @
var xDir = 'right';
) M( t; J% {% L2 A' J7 r# svar yDir = 'down';
* W" w* V$ c5 v3 S' N2 mvar superballRunning = true;
, e4 P2 C- E$ Z" r7 H* b# e+ ]/ bvar tempBallSpeed;
2 x+ S& P% T; U: o( D, z! avar currentBallSrc;3 I. b6 n( j/ _1 u+ J, |
var newXDir;
0 \! v0 i' Z! G8 e* j5 k. wvar newYDir;! ^! ~( k: y) N! E4 Z1 s/ \ V
6 f. P$ f; n' r P+ bfunction initializeBall() {
% n& _9 [! {& N if (document.all) {3 h% G( D4 N5 u7 e |2 |
xMax = document.body.clientWidth- w7 T7 _% e! v# _" o+ [
yMax = document.body.clientHeight
0 x+ |& k- Q$ d: ] m3 b: ~ document.all("supertext").style.visibility = "visible";
( _# ]) @8 e! f contentWidth=supertext.offsetWidth
! E) R/ O, V( n3 o9 N contentHeight=supertext.offsetHeight6 h$ e# d1 ?& Y+ K& c, _! m
}
( ]3 ~/ H; T' ` else if (document.layers) {2 F3 i. a+ S1 Z# d
xMax = window.innerWidth;* l$ u& R6 m0 r* h4 ?4 g0 g/ W
yMax = window.innerHeight;
9 B/ \6 _6 Y" a l1 V( _; z contentWidth=document.supertext.document.width+ e3 o& k' t# H. \ e/ s: q
contentHeight=document.supertext.document.height6 g, }$ k7 c6 c( s( M) |
document.layers["supertext"].visibility = "show";9 C; J; L) B8 }" h$ T
}
0 l. x+ ]& B4 }/ }0 b setTimeout('moveBall()',400);6 d, l% Z% V: V' B
if (hidetimer!='')
0 X) ]& W3 d3 g/ A setTimeout("hidetext()",hidetimer)' B+ |! N8 g4 f6 K
}
0 t' o" X0 @! S& }4 [- @% O I. S+ X& V1 f: {( X1 f; P& q* U
function moveBall() {3 v: r' `& Q5 q% W ]$ P
if (superballRunning == true) {
7 c* b) b4 o( ~9 _ calculatePosition();5 w1 M% r$ G [" L- E8 E
if (document.all) {. j; D, ` Q: e! j! @! t
document.all("supertext").style.left = xPos + document.body.scrollLeft;
# e2 Q6 {8 ~+ V: S' m document.all("supertext").style.top = yPos + document.body.scrollTop;
Q$ i: N9 h9 f% r Y" N0 Y }% x- S7 @1 {* h7 N7 Q
else if (document.layers) {/ t& a2 ~( {+ F+ `
document.layers["supertext"].left = xPos + pageXOffset;4 \3 r2 f6 Y) @( n; I" x% g8 |
document.layers["supertext"].top = yPos + pageYOffset;0 ^% y# v+ S- z" v# h/ ?1 `# u
}
; e8 e' {- N( M) q4 k4 M* S0 A animatetext=setTimeout('moveBall()',20);* t1 p) m' g% O3 T
}
1 Y9 x9 q5 R0 L; S! U9 \: X9 U }
& b. r7 C3 U5 V! K6 j; s# C! G0 T+ h5 }/ l& H' O( r5 Y9 }+ h8 O
function calculatePosition() {
6 H0 N. h& f4 f; p& P: h( k if (xDir == "right") {
, ^) d! T$ S' M$ z" G4 E; k if (xPos > (xMax - contentWidth - BallSpeed)) {
; m1 Y# x/ c, `5 T3 U* k" K) b xDir = "left";
) d7 W8 v* m' s, r2 Q8 D }
* M8 y/ Y8 g# r' @ }) f" A: S: c& Y
else if (xDir == "left") {8 Y) i7 @8 L+ T9 A
if (xPos < (0 + BallSpeed)) {
; a) x/ G1 Y+ a: T5 m xDir = "right";. d. `/ a2 e: G0 _, C/ v
}
8 v+ m9 H1 L2 D W9 P! Z }
% V k. G6 A" `/ d; c. w if (yDir == "down") {" M5 s: u0 T" P; t! J
if (yPos > (yMax - contentHeight - BallSpeed)) {
" p3 S5 }* `% K0 ]1 y yDir = "up";
% p8 Q9 A' k/ w; Y0 S }# v, T0 Q0 ]9 y1 n0 D+ E' R8 `
}
0 H, A1 O& y6 s; Y else if (yDir == "up") {
q! A& ~2 i% {7 Q5 f if (yPos < (0 + BallSpeed)) {
2 T- J% i1 l3 e yDir = "down";
' _/ ]+ I% G1 n5 X }
3 t& P4 I9 t* n }
! d# \) A5 `6 J' J# A: z) | if (xDir == "right") {
0 J, P+ f) @5 k; S f E4 n; m xPos = xPos + BallSpeed;" M. h& N" W) ^' z, u0 N
}
- ?( j* b" W2 d5 k/ W* t else if (xDir == "left") {! W Q% [+ r9 O9 |
xPos = xPos - BallSpeed;# E* [+ t4 |2 G1 N; B D
}1 b) h9 [. d! O( }* ~- K
else {- {' U: |& D' C W; t
xPos = xPos;7 }1 V" L6 _. c% |
}
" X8 x$ \8 n, \! A r if (yDir == "down") {5 c; l, b. N8 n2 y# B
yPos = yPos + BallSpeed;
0 k6 a# p; s/ _, g1 ^" p6 X! Z6 c2 w! L }
; K- }- e. g0 v5 S0 o; k else if (yDir == "up") {& y7 e5 ]$ g6 B/ {9 [
yPos = yPos - BallSpeed;0 a" ^$ h, Z2 v& b
}# I/ i/ M& M6 M9 S
else {# v- O/ Q0 s. l/ v) h
yPos = yPos;' e% x, I" K* i: U6 m
}
7 S. U# {' L& n9 z" \) d R }
) M% E. ]6 {0 e3 q0 }- c
# U) I* r- {0 m: ^, cfunction hidetext(){
3 r! E4 x' \% t% L8 ^if (document.all)- Y9 `; t( [2 S" \4 h& X" U
supertext.style.visibility="hidden"2 j+ J& h5 x" ]3 y8 j! x7 R' c
else if (document.layers)" S4 D H1 a) x
document.supertext.visibility="hide"
( B" f/ I4 H+ N$ UclearTimeout(animatetext)) I* d2 T& C1 t
}
' c4 y. }3 f. B+ A" m4 }$ {% B F0 |) l5 g% v C" r) u
if (document.all||document.layers){8 \1 a; S' _6 X% P, |
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
8 m4 Y' M0 g( |8 _/ F4 z8 Zwindow.onload = initializeBall;
8 T0 @4 j1 j3 q+ n; N2 _2 Mwindow.onresize = new Function("window.location.reload()");
+ P, E7 `+ W& `5 D}2 q1 ~2 X( Y$ X- X- y# t
8 X0 n$ M- r, W3 H
</script> |
|