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

|
网页之不断弹射的文字-特效
<style type="text/css">* i- t& }3 C4 d$ O# ?; \
#supertext {- r4 `& y: W- k- g7 J
position:absolute;5 H; w1 Q- ?5 x1 ]" W8 E
left:0;
; m( `9 d/ z+ M. ]top:0;
' }3 ~& M8 u1 f9 e9 e/ `( kvisibility:hide;
- x- E, n8 k3 k1 pvisibility:hidden;
0 H$ ?! v. G8 B% z$ q l}
- q8 X+ W% u7 w: f</style>
! j! j, t' u7 A& G A6 t3 W<script language="JavaScript1.2">; m. G/ d5 S8 ]" a( G
<!-- 改变下的字体的大小。颜色-->
8 l$ Z0 Z7 G- H2 i3 h( D. V+ L* |var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
' c7 {' o2 T, t/ S& C4 gvar hidetimer='';
# y( |) t j: ~ s4 Y; H! i- n<!-- 改变下的弹跳速度-->; B! ?5 K7 b5 x" n: u
var BallSpeed = 20;
* V0 B) Y% T4 Q+ W' pvar contentWidth;
% p, U5 i9 p8 x1 ~$ avar contentHeight;/ t- ]+ z% S0 \$ Y/ p& P3 D3 X
var maxBallSpeed = 50;. t) Y. e" d* q4 O& Z
* U: `. Z8 w4 O7 C0 t" T2 V
$ Y X e& D+ A- n- Svar xMax;+ s6 Y$ Z8 A& a7 F3 R* A# ]
var yMax;: a" t; r. o# f/ C+ A
var xPos = 0;
5 X: \8 y$ {! w# [var yPos = 0;; i0 W) r }# t6 F' I0 J3 d
var xDir = 'right';7 I$ d2 W1 A" u
var yDir = 'down';. g- }, T# {) b
var superballRunning = true;
$ Y% w }2 O7 y, K' D/ b Yvar tempBallSpeed; b: u: m3 n: v1 ]2 m
var currentBallSrc;
3 C9 w0 S2 Z; o+ ~( N4 mvar newXDir;: C# x# Y' J6 n
var newYDir;
! H7 w' c' h6 r2 I+ A" r/ }
' T/ g8 W5 p8 M6 {4 }function initializeBall() {
( P# P) u) n- }% L& H) B g if (document.all) {3 y8 f: G5 n) b8 z1 u
xMax = document.body.clientWidth
5 h. @$ B0 w+ R* Y+ y yMax = document.body.clientHeight
% J$ z( v# f5 }+ { document.all("supertext").style.visibility = "visible";
. k% {5 q; V2 ]% G8 }& n contentWidth=supertext.offsetWidth- n. L/ {. X# i# ^' z N, W
contentHeight=supertext.offsetHeight& g8 p8 G, ^/ S5 n. E+ V" }9 K
}
( r! L; x: v# Z) ^9 `1 _, { else if (document.layers) {8 }, `' Z7 }& a% g* S# }
xMax = window.innerWidth;
2 W3 T e5 z: x# n yMax = window.innerHeight;
: {6 O( M! v" y y' k contentWidth=document.supertext.document.width
7 A5 E: T9 ^" B. T# I! l/ L: p- ? contentHeight=document.supertext.document.height
8 p0 c( ~8 ^$ b( ^8 ]( e y! ^! w document.layers["supertext"].visibility = "show";0 R: j: P2 i8 ]- v/ G; X" Z% ~
}
" h8 K+ ~4 L; ~ s- s* i3 o setTimeout('moveBall()',400);7 F* F% _: H0 c$ c2 }" W' G! m
if (hidetimer!='') h: X& y' J' v! q* q/ D
setTimeout("hidetext()",hidetimer)! D# P5 H. ~- b! Z4 C( @0 I
}
( ~& \! t4 s7 O( T
. }. x) p3 t/ d" w7 k Dfunction moveBall() {( V" K8 R# _- t5 U/ |! j( o0 h) u
if (superballRunning == true) {
2 r: m* I# g2 |: m calculatePosition();" a& Y- o1 a9 G( j' b& B: J* m% o N
if (document.all) {' ^3 H* u# |: h4 J8 S+ Q
document.all("supertext").style.left = xPos + document.body.scrollLeft; K3 Y- I& K# g- t* @
document.all("supertext").style.top = yPos + document.body.scrollTop;; j* {: X) V' A5 G ?
}
$ Y, I" j4 U2 r5 R ]2 @) i6 J else if (document.layers) {
8 Y$ r( }5 u \& i0 [" W document.layers["supertext"].left = xPos + pageXOffset;9 J9 a& Z1 u6 Y1 m$ y, x
document.layers["supertext"].top = yPos + pageYOffset;3 o+ f* L* ?& A
}
& `5 @- a \) W0 T8 [, [7 f/ ~ animatetext=setTimeout('moveBall()',20);
+ ^# x+ e1 c: O. d) h: W% i4 F1 H }
' e* x1 C" @% Z- l! u }) H; }: }7 z5 y' s! h, N
L9 B' B9 c0 ^' @7 |function calculatePosition() {
, @, X9 m2 t3 T4 J4 d if (xDir == "right") {
, T$ B( X4 h9 U if (xPos > (xMax - contentWidth - BallSpeed)) {
: e+ g, V( s& s8 P, v4 V. a xDir = "left";
3 X4 d4 e. `' O1 ` }$ ]$ w0 |7 E8 G
}4 r- b+ {) s7 @% y
else if (xDir == "left") {
7 d+ ]1 T A. }& p B- E/ c; |/ [ if (xPos < (0 + BallSpeed)) {4 d: U+ u4 w1 T0 f$ C; P
xDir = "right";
! x# n) r* d: P# l5 h }9 L) v7 S( t m* I
}3 J; @! i8 k6 p; m( _& f* t
if (yDir == "down") {
, K* d. E: F* @% a( I# d$ O if (yPos > (yMax - contentHeight - BallSpeed)) {8 V) C" J4 X7 l6 p
yDir = "up";
?# E: H2 v+ L6 d }( S; A8 B5 a7 x1 q
}
+ B8 b; H% [1 @" |; l9 ?* `6 l else if (yDir == "up") {2 F! k' m% q% O2 |
if (yPos < (0 + BallSpeed)) {- t1 `: t' g; }! j' V" f
yDir = "down";0 D- W0 {* z; |: g5 o
}
$ P3 i; H2 K% a' s7 [0 x }4 [+ x9 Z& k: S9 Y- u( L
if (xDir == "right") {
- |: S P8 ^7 ~% |; K& B$ ] xPos = xPos + BallSpeed;/ S/ |9 {0 A( m
}( ? l3 t- D% t7 ?- k* R# l
else if (xDir == "left") {) t" z8 f V9 b" Q/ \
xPos = xPos - BallSpeed;/ @+ H e2 Q" b
} Z" v6 u6 e. @# `( ?
else {4 b# E3 A; e( o: U
xPos = xPos; |6 l- W. J4 x% `
}. p5 T- M2 L1 s2 ~: O
if (yDir == "down") {
+ R! c( s: H6 | yPos = yPos + BallSpeed;& R/ N! ~! H \3 _+ U; x
}
: V0 I w* Z7 n else if (yDir == "up") {
6 I) ?' ]- W/ v# l yPos = yPos - BallSpeed;
: b, O4 r, u4 {6 G }3 c" B8 l* K% p* h5 L2 H9 J1 G3 E
else {
. ~; I: J7 F" y" N yPos = yPos;0 C6 x: ~& I0 W6 U2 a8 Q V
}
: h7 }* L) |" ]1 h }" j6 M5 u6 k) g) o# S
`0 T( e5 c, w9 V2 v& O9 X7 sfunction hidetext(){
( B- v2 i6 b9 J& iif (document.all)+ \2 x4 C& u5 _% U
supertext.style.visibility="hidden"6 @, s- @( l1 j
else if (document.layers)- y" d3 m% |& c) O/ w
document.supertext.visibility="hide"! D2 d# ~/ ~: P8 h; g! n7 Y
clearTimeout(animatetext)
6 o0 W* G7 n. }% |" M# R* T; V7 _}
- H( {" |1 }6 i9 @/ \+ e* x% @* o* K# j: g
if (document.all||document.layers){( w9 @" R! M2 r4 {- Z! T
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 e+ ?% E% c# n& g% }7 Wwindow.onload = initializeBall;2 e6 z( s( i1 x& U$ p5 F3 Z4 y
window.onresize = new Function("window.location.reload()");
/ a' J0 Q) z8 Q$ @* K) W) e1 r}1 g% H0 s' Y/ S* D
9 H+ C# S& ?9 y# E% Z3 D</script> |
|