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

|
网页之不断弹射的文字-特效
<style type="text/css">
- g4 s! A( X! {& a#supertext {- O: h* d4 A0 _; U ~
position:absolute;5 O3 O- N7 ]# B' B; n
left:0;
5 J1 G' w& m% x' m$ K# itop:0;; N, r* j3 U8 U$ h
visibility:hide;
T0 k. K8 [1 ], N4 P- [4 Bvisibility:hidden;
; I3 A) L/ y1 Q' U) g g ?}: q: [' I0 J9 C& x9 H, {$ w1 I
</style>9 y. s2 b; o `; E# w5 W: y7 b
<script language="JavaScript1.2">( p6 F, j/ G( ?
<!-- 改变下的字体的大小。颜色-->3 }7 R) l/ M6 [! {+ `8 R& P! N
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'$ K' _+ }& R ~8 `* q5 w9 O
var hidetimer='';
0 E% b5 ~2 P" H) j<!-- 改变下的弹跳速度-->/ x/ O4 a) h: q7 w; j# \3 G
var BallSpeed = 20;
/ H6 B B9 f: n3 I; Dvar contentWidth;5 {& x" W: l; T: n+ T
var contentHeight;! Z @ I& z( P) z( u
var maxBallSpeed = 50;
; X: X9 t" ? X2 I, O6 h) h; E0 {2 v2 W, l
) g; y8 P$ D9 P8 c: ^2 b
var xMax;) q% }9 [& x H" C
var yMax;
' X" M& |& g! e) a3 i$ |* Yvar xPos = 0;( V g6 E8 H/ f! ^! c
var yPos = 0;
/ u e5 Y8 @# R5 b; _% rvar xDir = 'right';9 f" }8 _ ?4 ^4 j5 Q6 }
var yDir = 'down';
7 t/ \+ Y" k& [& a5 g6 lvar superballRunning = true;) _; c5 o) r8 H' g5 R1 S
var tempBallSpeed;) i/ @' y6 k# V
var currentBallSrc;
3 Y* W6 x; a( _; {- N$ Nvar newXDir;
6 s2 G7 W/ G9 k8 P2 z2 c- G. F& Ovar newYDir;
6 o9 x! a- o% T, ]4 |; \8 C
# i" c2 {9 O7 w Rfunction initializeBall() {9 k9 \, `) h0 e& ^7 l D' u+ @
if (document.all) {
" B! `5 B N2 l6 z) ]" Y5 p Q" o xMax = document.body.clientWidth
6 B' [# r0 d( y9 ]. ?; B yMax = document.body.clientHeight
' @+ L$ z4 P+ c; W document.all("supertext").style.visibility = "visible";1 @" g6 B. j( X
contentWidth=supertext.offsetWidth
: ^* I( \) T6 n/ {+ u- _ contentHeight=supertext.offsetHeight
% S0 e, }) A4 r( ~" z0 o s5 T }
. ~2 Z7 h9 ?4 m7 K8 `" u else if (document.layers) {0 ]+ J ]/ p$ F5 B, i" y' k
xMax = window.innerWidth;
2 C2 p8 \) U/ `: ~ yMax = window.innerHeight;) X% u6 ^9 J. x3 c. }, k* V
contentWidth=document.supertext.document.width
/ m% z& D+ I0 o. y/ S contentHeight=document.supertext.document.height) [0 Z. y# E8 W4 w3 o5 \
document.layers["supertext"].visibility = "show";
* T2 G+ ?( ^/ I8 @ }
- g' d: `0 T* `, _. V8 K8 Y setTimeout('moveBall()',400);
) T9 O6 _+ @! X5 l# ? if (hidetimer!='')0 o; V8 k$ _. T" z. |8 i
setTimeout("hidetext()",hidetimer). p) z. v+ j* g# L
}
3 f" L) ?6 D6 o1 x1 r! |6 m& m+ @5 }* O! m& w
function moveBall() {
0 i [# Y, f% h7 q1 o+ ^" ~. p% F if (superballRunning == true) {9 a6 k8 ?' B: `$ Z
calculatePosition();
6 p( o |# [8 q) U; r if (document.all) {* N) @7 o/ K2 O6 x& i9 \
document.all("supertext").style.left = xPos + document.body.scrollLeft;
: J6 K0 M1 K0 C r$ o) M document.all("supertext").style.top = yPos + document.body.scrollTop;
+ y+ y2 [9 x: k7 Z }" n! b% k3 T. ?1 a
else if (document.layers) {
+ n; C# V' e5 E* E" E8 X: {( S# Y document.layers["supertext"].left = xPos + pageXOffset;
+ n( c# T6 r( N* g0 q document.layers["supertext"].top = yPos + pageYOffset;
; x" Z7 `, T8 H) @/ M }. @4 b4 k% g9 D" b6 N3 O0 D
animatetext=setTimeout('moveBall()',20);
# L7 F L0 z# ~ }
! V( f1 u4 }6 f$ |; d }* w- c4 w# Q* B! D' H8 u! i
8 Y& u/ D) J2 S/ g! Bfunction calculatePosition() {9 q" L- i8 ~6 @+ ]0 c& g! K6 ?. k
if (xDir == "right") {6 A( {7 C) R- k- `3 V
if (xPos > (xMax - contentWidth - BallSpeed)) {8 `1 \4 ?# o' @" k# b
xDir = "left";
9 k7 u' o* N$ L; K" D4 C4 b }
" t. ^- i% C% w4 u2 m }" | g. g' s/ k7 ?" L
else if (xDir == "left") { n. P u5 h8 I7 N& I
if (xPos < (0 + BallSpeed)) {
+ R" X8 ]) ~- l) s/ P0 }+ j xDir = "right";/ x# h3 P. p) z5 e1 M
}6 h( x- ~! `% J: N% c/ o, i
}5 A; H% F2 j( o
if (yDir == "down") {
4 Q- c$ p, ` T0 C if (yPos > (yMax - contentHeight - BallSpeed)) {
$ w# i% V' z+ c* Y: f yDir = "up";, i4 Z- a, d. ^, m
}
. T! d# u* F9 u; ^ }
q2 v6 k9 i9 h' x% U else if (yDir == "up") {" `0 _" u2 S8 ~3 G/ N/ W5 h
if (yPos < (0 + BallSpeed)) {3 b, z9 T( m/ X w$ y( W7 N
yDir = "down";
% z, W$ M! G! T$ p }
3 l6 q( }- o! V8 N# a( { }! b: s' k7 f5 i% K; v
if (xDir == "right") {
0 E" ^: Q6 e: r: V; y" K/ l xPos = xPos + BallSpeed;# l. U- F, H |/ a! J0 z! w! s
}# |" v( x+ M0 ^' |
else if (xDir == "left") {
( S E- n+ p4 l! w; v1 W: ] xPos = xPos - BallSpeed;0 ~7 W2 t9 `! A% q5 D
}4 }9 o' T& p4 U1 i. s& E5 H
else {
7 Y2 L9 Z+ T$ q, ]. F2 }( w xPos = xPos;1 d7 k+ n: y/ M( ~
}' ^2 q$ v" R# m8 R2 }8 P
if (yDir == "down") {- ?$ V) _, Y: J3 d
yPos = yPos + BallSpeed;
9 L& a( r$ X g$ X$ v0 m. F; k }
, L, j* f$ f5 S- p else if (yDir == "up") {
+ t" t, W5 V5 I7 D: r' [ yPos = yPos - BallSpeed;3 C! R" F9 G4 R# L. H! e1 r% F( W3 u
}: j% b; d! h: J6 N8 \% f' l
else {* @, F# J& ]* o
yPos = yPos;
+ C/ [; z5 p& i7 F$ ^ }# C' h d7 }) c. r
}
8 _8 `: f2 F9 ^8 h4 S6 i, I0 B5 |( u
function hidetext(){
$ d! X9 w$ }) h; I0 I6 ?if (document.all)
' V9 J1 ^; @( d6 C' H& x3 vsupertext.style.visibility="hidden"
. M7 |4 P$ r; Y( i; H p2 S e' selse if (document.layers)
5 F/ t. A; p* {$ m+ T* Bdocument.supertext.visibility="hide" M/ X& h- F9 o2 t, D
clearTimeout(animatetext)9 Y: c, f, S8 n0 ^: a
}
+ M/ t. n! K. A4 y$ t/ ]: M* K2 C
if (document.all||document.layers){
, \ V) M( U2 ?) `$ R' L* j# fdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
! K! v1 y- D( \3 E% Pwindow.onload = initializeBall;
. v: _9 d' v& @7 J/ u O ]: j& rwindow.onresize = new Function("window.location.reload()");
e0 b7 a5 F/ d}9 P; Y5 E" g* u* @ H: \( R
2 E# t! _' E$ |5 n# S8 b</script> |
|