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

|
网页之不断弹射的文字-特效
<style type="text/css">
, j5 }+ i% |2 @0 E! T1 \& Q1 F#supertext {
: ?1 C u/ R) U7 ?. tposition:absolute;
0 `, [' }6 m8 M+ b( oleft:0;* |! x. O% H3 u/ ^" ^, H4 J S9 Y; N
top:0;
2 C/ i; Y3 L! W }" L7 ^+ Avisibility:hide;
6 ~, O! z+ Y) ?4 Jvisibility:hidden;
, S3 A0 w) N1 c: [8 q2 }}* Q2 |9 q& g9 F: T1 K
</style>
3 O9 y0 D% Q' I/ ^3 Z' h<script language="JavaScript1.2">; L7 ^& X r+ k2 }
<!-- 改变下的字体的大小。颜色-->
3 T% C& \1 s6 b. u4 c% o/ jvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 ]' B" T! y" M! ^0 ~( hvar hidetimer='';
7 X6 y& m/ T- E7 {7 Y- W9 [+ r<!-- 改变下的弹跳速度-->
0 H6 z1 G" C& i2 }1 ~9 Rvar BallSpeed = 20;
' S# `( P. ~! Fvar contentWidth;4 M+ Y% I& E( J# a) Z e7 n
var contentHeight;, s0 d9 R; N. b6 F* {$ P! m
var maxBallSpeed = 50;6 E! x2 E! Q8 G ~, X
3 P2 b# X8 c4 r e8 }
+ r) z. L. e) d& u" h2 Pvar xMax;
5 |+ k7 T# g4 _1 Q6 Pvar yMax;
2 G) H" v9 ^2 X+ wvar xPos = 0;
" y: q+ N6 \2 |$ D7 _& g* p( mvar yPos = 0; b; n$ d( e3 ]( |
var xDir = 'right';+ o# ?1 f- T+ W0 t9 ]$ t9 z* [' Z
var yDir = 'down';9 T) @* L( ]( T0 T
var superballRunning = true;
; D! d; G% L' O; A9 p/ Y6 Jvar tempBallSpeed;
, \$ V# {# i1 Y0 n8 v& u$ ~1 wvar currentBallSrc;! p; Z4 \" P7 p" o7 P; P* s
var newXDir;- T1 Z( I9 d- ]& W8 B, m
var newYDir;
* F* R4 ?: j$ o( r1 x5 L# b w1 G! u) ~6 W4 H0 ~6 t! p* n+ I
function initializeBall() {
3 w7 r! Q6 n5 F! ^ if (document.all) {
3 @5 j" J, X7 K& O9 {! d t xMax = document.body.clientWidth6 P+ k! Z; H& Z6 \& m5 @, @
yMax = document.body.clientHeight) c! @$ [: N& H8 x
document.all("supertext").style.visibility = "visible";
/ H2 p" K3 [$ {8 v contentWidth=supertext.offsetWidth
1 _# G0 c) r9 c contentHeight=supertext.offsetHeight
( ?: K! u/ @3 k# t6 Q8 u1 ~ }2 D5 }) N, q0 j% |) h+ [* _3 \
else if (document.layers) {2 O. M8 }2 x7 y# @! @- _; I( B4 ?$ u
xMax = window.innerWidth;! j! _% N8 V4 S# @3 r& n. W
yMax = window.innerHeight;" H+ P" l) @. T0 H- F& ?
contentWidth=document.supertext.document.width5 T- q5 x- w V U$ @$ x1 K
contentHeight=document.supertext.document.height
+ p1 C1 P2 F3 b/ e4 `9 `3 C document.layers["supertext"].visibility = "show";
8 z( `2 K4 s8 F) n S6 e }! `) j' d, _0 f/ I% E+ l# Y
setTimeout('moveBall()',400);
5 X8 I6 T% E5 @, L4 C- N( Z if (hidetimer!=''); G9 O/ u8 n3 v. [5 r1 O5 k
setTimeout("hidetext()",hidetimer)8 V* g5 F$ a9 m
}
0 Y5 M6 p+ @+ _ P7 _5 `
. Z2 \2 n2 K( i1 y0 h% lfunction moveBall() {9 P4 b& t" x6 `* L# W! n* t
if (superballRunning == true) {
3 N l8 `; i3 | calculatePosition();
2 Y1 n# T4 y1 b" l8 A O$ q" D if (document.all) {
9 y# @: e" S. T7 N [ document.all("supertext").style.left = xPos + document.body.scrollLeft;; x& Z [ H- T/ ~2 l
document.all("supertext").style.top = yPos + document.body.scrollTop;# |" L' @; d( u, ~4 h9 G5 F; A
}# w8 }. G2 W$ X
else if (document.layers) {
3 W3 A" J+ `! t' W6 u document.layers["supertext"].left = xPos + pageXOffset;! I0 t2 Z0 S$ q* E
document.layers["supertext"].top = yPos + pageYOffset;/ h" S& n5 O+ H( S5 a
}
/ k' A! S+ ~& e9 E' g5 T animatetext=setTimeout('moveBall()',20);$ h7 m0 x; h' j) y
}
# E3 P* Y4 u+ ?) `3 i, W- J% A5 s6 C }! J6 h2 `# p& N- P. ^; T8 ]% f' l
0 U# T+ {) u8 l, ^& N; k, @: Zfunction calculatePosition() {" v) d; }! W. v$ h2 B# U& ]" G: B, I
if (xDir == "right") {: ~1 N; d% D+ y$ P( o5 Y
if (xPos > (xMax - contentWidth - BallSpeed)) {
2 I, E6 R) [' g xDir = "left";
$ O% z) B$ `& g1 Z }
, G/ T x% q+ e" [ }
( ]2 ]- D! `0 X8 }3 w else if (xDir == "left") {
8 e* |2 a0 N% I2 @- r7 O w+ a" q. z if (xPos < (0 + BallSpeed)) {0 L/ j1 G4 i5 x* n! j
xDir = "right";
! X8 u U1 Z: Q) _6 X) H/ m }
& F7 w5 G7 l1 P3 i( D0 Q5 `3 @% i }
3 o& Q9 ^8 \( l; ~8 D if (yDir == "down") {
$ w' F$ Q! G3 |3 d if (yPos > (yMax - contentHeight - BallSpeed)) {
+ P9 `0 o9 }6 W9 _2 ^1 \$ Z2 ]5 n yDir = "up";4 H) |3 {2 z9 ^" m5 X/ G! T, K
}8 F9 d- q, y! a( W. a# Z8 Z
}
! P# `. |: l9 P else if (yDir == "up") {
1 | [/ m; n7 q7 ` if (yPos < (0 + BallSpeed)) {3 W* P( ^6 P; P) W
yDir = "down";& ^3 n! ~' L! c: f3 q1 j
}# r3 b3 h4 z4 \/ r; Z) r) B( ?
}
& o* `- L- S+ e" X; I2 H: S if (xDir == "right") {8 ]1 Z& c5 h% V( |
xPos = xPos + BallSpeed;
, Y( L; P1 ^; o' ~9 A+ f }
, m* t) u1 X( S. m1 Q% x3 D$ k( f0 h else if (xDir == "left") {" U( y. U* x: ], ]/ p+ t$ |
xPos = xPos - BallSpeed;
& ?# ?) R0 I" g8 ` M8 ^ }
# n5 {, d* M( Y2 T else {
I: y2 w. }' _! d9 Q/ O: x0 V! g xPos = xPos;
+ r8 a8 N8 P" i/ X( W }# h: r- y) Y8 d" K0 W, m1 D( z
if (yDir == "down") {/ Z. Y: Z3 e! r1 i
yPos = yPos + BallSpeed;
# ]$ l2 J0 a+ R4 r' T }
V: h, g9 b( z: [6 ]7 u1 Q else if (yDir == "up") {+ @2 ^' f& E- X- G$ U H
yPos = yPos - BallSpeed;7 |0 y( z# F: W) B
}2 p* Y9 x3 _0 A2 b* Z
else {. V. H0 p/ ^) }6 U
yPos = yPos;- |6 A, W0 k2 C- F8 C7 [
}0 g; W6 ~1 @7 j5 b; t1 f8 v
}6 }9 B, m$ x3 N& H( L w
4 Y3 C+ h' m% }$ T2 W& ifunction hidetext(){
7 G* Z- ^2 v5 N1 M# u6 Z- k+ r, o Nif (document.all)
* I: @2 A( \% c( w. t+ B* ?( S) Z: Psupertext.style.visibility="hidden"0 R t2 a. ~/ W3 H; T
else if (document.layers)
" R7 ~ N. A# S2 g( Kdocument.supertext.visibility="hide"
. | M+ X5 ]" TclearTimeout(animatetext)7 v7 C7 B3 b- @! t4 G0 z+ v
}8 s) I1 c$ T0 o" x7 [4 b
% }4 g1 H: r& C1 Z
if (document.all||document.layers){
$ K5 B6 o5 G5 |' g, _1 Sdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
; C8 p, Q j$ N( Iwindow.onload = initializeBall;
, R- @& t: h( g; Y4 }window.onresize = new Function("window.location.reload()");
, ^+ F; s' F( ~} k- p& T% v$ W6 o( F1 W8 Y* W
! P( ~; L1 d4 X</script> |
|