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

|
网页之不断弹射的文字-特效
<style type="text/css">
9 D* r# I" _$ U4 y# C#supertext {5 T; ]& h) j; H
position:absolute;8 ` E- l- W B6 E0 n! a7 {; `
left:0;2 _5 e: Q3 [- |
top:0;
" a3 N0 t! p5 ^4 Dvisibility:hide;
' P3 C2 z: s5 f8 ^$ jvisibility:hidden;5 `1 [4 R& u3 ~* x8 u
}- Z! P! I |: o/ {
</style>3 {4 |1 y& _& W9 c
<script language="JavaScript1.2">) l. ?! i5 S2 X, V' o
<!-- 改变下的字体的大小。颜色--> i l$ E& e5 Z
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ \; c# C& d2 |# C1 I0 L% O4 ^
var hidetimer='';
' }" h& W& x7 L7 M- t& d* D<!-- 改变下的弹跳速度-->6 j* n& N( }- B
var BallSpeed = 20;
* ?5 s5 k6 r: V7 Cvar contentWidth;" w8 j4 u% U d1 I$ p6 M8 ]7 Z
var contentHeight;2 P! P* V: N( c. u) |
var maxBallSpeed = 50;
4 _0 B3 b) B1 [# H3 f; f! o9 j0 k) n, T& z; ?7 ` {9 c
: X) o7 l: Y5 h0 ~
var xMax;) i; e7 z8 x2 A0 g; D& S+ ^
var yMax;
9 m1 x( D( u$ p) J, `var xPos = 0;8 X) A: K' O/ H8 B. q. h% u: q
var yPos = 0;8 K3 |" g( t; K2 j! l* v
var xDir = 'right';
4 X) r4 d% k& n, F5 gvar yDir = 'down';
/ @, T- j- B0 i' t; N& u7 k* ?var superballRunning = true;5 t# @% d, }6 t- N
var tempBallSpeed;+ n) P4 F! V- D
var currentBallSrc;; V1 c* c: G* c Z, o, Q1 m V
var newXDir;1 h: x% C/ U' w
var newYDir;; V& }% p* a% w8 N+ o; ?
: ~9 o4 A: D7 G8 r2 z
function initializeBall() {
* Z- D( V/ D3 c if (document.all) {8 S' P1 f5 j0 `* l( ?6 K1 j2 m
xMax = document.body.clientWidth7 f9 {0 c6 v0 C% |- U: d# { B9 h+ ?
yMax = document.body.clientHeight1 T5 F9 J" W# G. d
document.all("supertext").style.visibility = "visible";% y4 _$ d. Y/ K& m7 }
contentWidth=supertext.offsetWidth
- V# A( [. l+ \' ]) `* I7 w) z) N contentHeight=supertext.offsetHeight |$ v9 e( \1 n2 B& R% Z
}$ r- ~$ n/ p1 C/ w6 m1 k
else if (document.layers) {
6 f, G0 z$ B( T xMax = window.innerWidth;
/ V6 n+ S$ p( I' }1 U% Q yMax = window.innerHeight;( j, p/ [& l# n8 m2 H$ h
contentWidth=document.supertext.document.width+ d: {& K2 X) E! F3 s
contentHeight=document.supertext.document.height# w5 W6 i8 x3 ^/ n( V" ]+ i
document.layers["supertext"].visibility = "show";: v. l Q; G1 Y5 Z6 A; [ p
}
# K) e* o" c, E" B) `/ R setTimeout('moveBall()',400);
: D4 e1 z/ ]+ K4 L; c, C# O9 z if (hidetimer!='')9 b7 y8 m2 W1 p
setTimeout("hidetext()",hidetimer)
4 Q( F9 v9 W" R5 c }+ T* `' h0 d& n9 t
; d. G' b! d* @+ M' g, ?. vfunction moveBall() {% B2 E1 I, H% h7 i7 Z0 u6 j
if (superballRunning == true) {
, L% C2 ^0 Z9 F calculatePosition();8 i5 f! e! U- p' E, r' M
if (document.all) {' N4 _4 q4 Y, R8 e( O0 P# Z
document.all("supertext").style.left = xPos + document.body.scrollLeft;
0 f/ z3 Y' X4 | document.all("supertext").style.top = yPos + document.body.scrollTop;5 q1 A! D( [. z0 I% @1 }) o3 h- E
}; n2 X% ]$ O3 Q. I8 [$ j
else if (document.layers) {; S* D% T. ~8 B$ Q8 Y5 Q4 F/ e
document.layers["supertext"].left = xPos + pageXOffset;
% z; G( o% X( i k document.layers["supertext"].top = yPos + pageYOffset;
' R* d# T" `/ ~( q- _$ {+ p5 U( r }
2 ~% G; y7 t) t" ~0 w animatetext=setTimeout('moveBall()',20);
( @/ h- ]. H& u& R }! N+ G' \% N4 d( u: C
}
# x U$ c' i* _2 l0 O$ G
! G0 R0 L4 y. w" r5 H8 Bfunction calculatePosition() {
% W. s1 s2 b! h4 J3 @1 H if (xDir == "right") {
8 X2 W* Y# o0 n if (xPos > (xMax - contentWidth - BallSpeed)) {
6 u$ l* Q( {4 r+ V) q$ { xDir = "left";5 w7 _0 L$ y3 Z7 e
}
2 E ^9 t( D4 S1 v }1 u& a0 Z r0 S ^5 n
else if (xDir == "left") {& w3 b- V6 H! o' a8 }6 }# O" I
if (xPos < (0 + BallSpeed)) {& }8 k! ~6 x$ ~1 z
xDir = "right";
$ F! H$ d, K( J" z5 M% u4 j* X }7 A# b- b" @; ]
}
) X4 M! S( }/ D! b& b- C g if (yDir == "down") {' b' j; m& `( i% @* C
if (yPos > (yMax - contentHeight - BallSpeed)) {2 T3 o& m' k2 R
yDir = "up";
7 B1 Q% B) \$ ~& a, j6 f- f }
; x, i+ A: s7 f& l& n' t( i2 s }, ]5 h9 Y( \/ j4 d
else if (yDir == "up") {2 S4 H1 U2 G; k R+ M0 i( d0 \' q
if (yPos < (0 + BallSpeed)) {
# M$ {" `# i& Y2 Q yDir = "down";$ }! w' n2 r& |- g$ Q9 U9 f. \( N$ b
}, I( R( ~$ j1 g: ]
}1 i1 }7 R. W& m# p$ o" K% E4 f# k
if (xDir == "right") {
% i: x, _# ?+ Y% M xPos = xPos + BallSpeed;
( |- f8 |3 x* u+ e4 ]4 S }
3 m# R7 u( t: h else if (xDir == "left") {
% c3 B' i9 @1 a# b4 y1 Z+ q4 w xPos = xPos - BallSpeed;
3 f9 Z; @; [- ~4 d. A7 C }/ X" q7 @ N3 `9 C4 b
else {
3 k9 X7 E+ a( ~( _/ F8 j xPos = xPos;$ T6 C4 j6 b( x Y$ w
}8 V( ~6 v) F% [' o
if (yDir == "down") {/ Q& V$ I7 k$ y. ?
yPos = yPos + BallSpeed;
& y4 u2 j+ H5 v! t }6 C7 [2 }" h" {9 S" ]( h
else if (yDir == "up") {
; z. L8 V% D" X yPos = yPos - BallSpeed;& ^6 M+ @, B! j, s3 ^4 ]
}/ ?. j# R3 I: e, y. H7 j: x9 E
else {
+ C: i& Q' j* ]. P/ S5 e- P* c yPos = yPos;% n6 T# ~% i/ U; f. V
}4 E# Z& Y. M- s: Q. j8 r
}
5 p1 @/ \6 o- u+ `; W$ F( h
+ _ F0 e( D: x5 w9 E( rfunction hidetext(){
9 H9 F1 K3 W' H2 X% x0 P5 Pif (document.all)
0 w9 p8 N7 p' E$ fsupertext.style.visibility="hidden"
* ^% N$ M! D% }+ ~# _else if (document.layers)
! N' C) B/ p' h5 a5 Zdocument.supertext.visibility="hide"7 I) m+ B$ _- t; C$ {+ U T8 P8 K
clearTimeout(animatetext)# d; F) i6 A8 a# z D$ M* R
}
u% ~# [ s. l) J( k$ {# d7 c y- F: t! G
if (document.all||document.layers){! a( J# c- i7 @8 _9 w
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
! O+ f6 _) ^/ n5 Pwindow.onload = initializeBall;
/ M% t# t6 s& |3 C9 _6 e' D, [! zwindow.onresize = new Function("window.location.reload()");
' E1 b* ]6 F: v) O}
$ l( J T1 h) I1 j
* x& @: f3 b U: [' X6 t</script> |
|