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

|
网页之不断弹射的文字-特效
<style type="text/css">2 a: v7 t8 l# w) f
#supertext {/ i! w# t4 _1 ~2 ?$ Q. R, s
position:absolute;* u# s% Q1 \8 q! w- w# ^
left:0;
% s3 A3 D! g ?- y4 G9 @% J1 h* c/ {top:0;3 ^% \. {5 T6 x) T
visibility:hide;
D6 w" B% ~6 m% E! lvisibility:hidden;: G/ y4 I3 M6 P- W/ D7 Y0 _
}1 x- A$ x4 g: ~6 o9 ]1 E
</style>$ i" ~6 B; q5 r
<script language="JavaScript1.2">& r$ s# W" f' w: o! Z2 V* \
<!-- 改变下的字体的大小。颜色-->" d+ Y4 ~; P/ O0 }) w) B
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'$ c' T c G" I2 M% B( D' q H
var hidetimer='';6 {8 U7 G8 n/ A( ^2 M
<!-- 改变下的弹跳速度-->
" ^/ E, Y( a# f2 I' z' N! rvar BallSpeed = 20;& x* b# I, M P8 t, |. ^4 k
var contentWidth; `) ^, @" O9 ~; O% `
var contentHeight;* J! i4 W. U& X. {/ N m; S
var maxBallSpeed = 50;, R5 a1 d4 Q7 E6 r$ h6 K% P* e# L
8 x' F, ]* T9 F. O" [% T, {/ A6 N- Q3 m
var xMax;3 `" l! F% |0 ^: M5 G+ P+ [
var yMax;
( e1 z* s9 b5 p# X9 w0 fvar xPos = 0;
# u c) z" y2 h1 R% m1 dvar yPos = 0;1 |1 D3 Z' f. M& E6 v
var xDir = 'right';2 u. o6 _. W* ]: P9 I: ~
var yDir = 'down';, `2 M( f, b$ N5 `: [
var superballRunning = true;
4 M7 q% d' w/ L3 tvar tempBallSpeed;2 J% J3 B) U+ b; K
var currentBallSrc;
+ {8 V" _8 }/ Hvar newXDir;
9 z8 o; ~* d; o# D% Z+ Avar newYDir;
* t2 ]. Z3 {& N1 W" i7 r' ]+ s/ b. Z# N9 W5 i/ z% G% y6 S5 j
function initializeBall() {& z! P: U* C* a2 Y
if (document.all) {) N6 i( N% X4 k/ B4 I. {
xMax = document.body.clientWidth
( u. W* L! K3 V# a% X yMax = document.body.clientHeight
. d3 f, k7 o& ` }9 O document.all("supertext").style.visibility = "visible";8 [, S3 H( c$ p) d5 A
contentWidth=supertext.offsetWidth$ [' p. z% f7 Z
contentHeight=supertext.offsetHeight' J; t8 Z/ U/ r
}8 ~1 K9 t7 ]9 u. A3 S- u
else if (document.layers) {
9 t/ @6 Z3 u6 B7 w xMax = window.innerWidth;
% ^# `- y, W5 a: Y& S% {# T yMax = window.innerHeight;
8 B+ c) w$ n8 Q* f' B contentWidth=document.supertext.document.width
6 w: e- u' Q& N- g% w) I contentHeight=document.supertext.document.height
8 r5 o3 a8 b+ u. P& F5 g document.layers["supertext"].visibility = "show";
; _4 Y; Z8 ?- { }
! F! A+ m1 H5 I+ u6 z setTimeout('moveBall()',400);4 S, q7 O# v' v+ B- j1 ~/ K7 _
if (hidetimer!='')
# t/ T# R4 N) _* F: [3 `' ] setTimeout("hidetext()",hidetimer)) \/ F/ v: |: ^& d1 v/ B s( P
}- c, I; W4 H8 \ O
9 [8 f) K3 L, y# W6 sfunction moveBall() {
" X, D: H$ Z' W& r' f; O# M if (superballRunning == true) {8 h. _9 c, \; g( D
calculatePosition();: f0 L- d8 v$ Z' \4 A5 X
if (document.all) {3 M: ^) D H. d/ f) ?# {3 @
document.all("supertext").style.left = xPos + document.body.scrollLeft;
* r; r) D9 a, F' U5 u document.all("supertext").style.top = yPos + document.body.scrollTop;6 H' X! m) `1 N. f$ X
}4 C2 h2 x* o4 L# W; v4 j$ W( V. u
else if (document.layers) {& A+ I2 @! k% k' e
document.layers["supertext"].left = xPos + pageXOffset;+ X, g3 M( j {
document.layers["supertext"].top = yPos + pageYOffset;) ]8 S: z& h+ R, E
}
. x4 J+ [/ M1 C/ `: y& _* w+ J animatetext=setTimeout('moveBall()',20);* U% K0 u9 r0 K+ i
}
* r( v' N; {3 F) |% m& G0 H: y }
$ i. V/ W& |( E& _2 K1 h+ W3 d! @1 a
function calculatePosition() {
' U9 y+ n1 y( I# L' M, A) }+ _" V1 g if (xDir == "right") {
- q9 {: [ Q* x) ]; `5 h if (xPos > (xMax - contentWidth - BallSpeed)) {7 p, X$ ]9 N# a- P* P% m) \& q; F
xDir = "left";
$ Y! S# w) m( _7 G }
5 j4 L5 t: ^* u- j }, ~/ }4 N2 S) a+ L; D6 T5 [
else if (xDir == "left") {
1 c7 I. Q- w6 U5 G4 e" C3 ^ if (xPos < (0 + BallSpeed)) {5 m% h4 C. x+ w6 N9 F$ @
xDir = "right";
+ c% `% U5 g" Y1 J }0 B2 e. G* M6 _
}
0 d: f4 K3 B! r! @; d- { if (yDir == "down") {
' I b& ]) Z- s! z! @ if (yPos > (yMax - contentHeight - BallSpeed)) {9 J# V# G# ~! n) u
yDir = "up";0 m V! g5 q* ^6 m
}
1 A5 W, y* ^0 l }
% H* V$ m& f' |7 j* N else if (yDir == "up") {3 W: i# D0 A" V, N ^
if (yPos < (0 + BallSpeed)) {
2 h! Y0 z: f' q8 @( C# D' J) @ yDir = "down";0 R h4 l1 z( H$ D1 h' H
}
3 F# [3 }2 C+ o$ [ k# ^ }
1 Z0 I( e, a4 j if (xDir == "right") {* f/ T7 {$ i7 g/ o3 M
xPos = xPos + BallSpeed;
0 X3 [ ~/ `) I }
7 q9 M6 g8 y0 I$ Y else if (xDir == "left") {: M' w: h* j; z, I+ W
xPos = xPos - BallSpeed;$ ?1 l5 F& b" v# T
}
$ f/ C. V- K4 k2 R( e: D% ~4 m else {" n9 [5 E5 {) ]
xPos = xPos;, Z | V; L- H# r ^" h, X# @2 d
}
# r6 f# S9 Y- z$ e if (yDir == "down") {1 [0 Z& b' K* `+ v- x2 x
yPos = yPos + BallSpeed;# a6 T( A5 K0 `
}
3 D) t" _/ V! N3 K4 f" ? else if (yDir == "up") {
' u/ J8 I4 [6 G: ] yPos = yPos - BallSpeed;
9 l+ }( g9 B: N# r0 A2 U; n }8 J. v4 c# N( @8 x9 q3 V# d- j. X5 ~( [
else {. C2 W! @6 I! ]
yPos = yPos;4 c/ a# x4 Q% L
}5 n- j& w8 q( P+ r( S
}& r6 M5 V( H4 P, \6 x' J. k( ]
$ [5 `$ m" u0 K
function hidetext(){8 i6 U+ X( J* m. ~& _6 N
if (document.all): s* l) k8 b: L. {
supertext.style.visibility="hidden"+ A3 u' _ U. q1 y; U: F; z
else if (document.layers)9 m* d6 P" ]+ {
document.supertext.visibility="hide"- A" v% Z1 L" @" y, z: c5 v7 t
clearTimeout(animatetext)/ E0 l# e8 `* K1 U) j3 B
}
4 V* k$ h& H) J) V/ P
1 | j( p7 V2 g n+ ^if (document.all||document.layers){6 |7 A2 a5 T- T' C; Z; X$ V
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
2 U9 @! \ t) v \4 Rwindow.onload = initializeBall;
) F4 T8 {5 U" q, @8 s7 Z2 X' twindow.onresize = new Function("window.location.reload()");$ o$ T( N$ U9 z
}, b5 a/ i9 I, e a9 M9 O8 b$ R
# L5 T% J6 n4 H3 G% ]% s
</script> |
|