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

|
网页之不断弹射的文字-特效
<style type="text/css">4 v/ S4 n1 [/ S
#supertext {4 |% H" f# s( S) c5 s9 r
position:absolute;
* s) L5 r9 Z6 s: z7 |3 A1 W4 Xleft:0;
$ Q, a9 ~( m j8 t" Ftop:0;0 a, ^( ^5 @; i$ b* ~9 I; D
visibility:hide;
# z# ?- O6 d6 Svisibility:hidden;
' c: L4 z1 M' |8 ^+ A}
9 q* E% D P) R$ v K" K: P</style>
) l, z" J4 C. u! Y5 D' x) k" Y<script language="JavaScript1.2">1 ^: A8 P: B/ q9 d ?& d
<!-- 改变下的字体的大小。颜色-->, k# @; c, H* B# \
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'7 i( _2 Z! c# K4 [$ U
var hidetimer='';
7 x6 K- e% `" ?+ O$ N& s<!-- 改变下的弹跳速度-->% W8 U1 o' i; l! {9 s
var BallSpeed = 20;* Q! A `; |* \, z4 l
var contentWidth;( V: @ j: d2 r j$ }
var contentHeight;/ t, z- f. c& g: y; A9 K$ a
var maxBallSpeed = 50;, V! }* G3 _; W- J
; o# O' n2 \/ K; q+ q% w/ C0 k
8 K- p/ g# A# S6 \' a# c. U6 a+ gvar xMax;
3 p9 c% D# Z; v, | p" y# ^var yMax;/ y5 V) s! R7 x; A
var xPos = 0;
c' d3 q/ |7 V& u, ]var yPos = 0;
: B) j' R' h1 W$ m& |. Ivar xDir = 'right';
* M, ?: R4 k( `9 v5 F' d7 mvar yDir = 'down';
0 D- C; {0 n9 u7 G6 L$ _& ]var superballRunning = true;
3 U# h g9 @$ cvar tempBallSpeed;
! B# d$ A" a, Q0 z; r3 rvar currentBallSrc;
# u, j! ^& w. svar newXDir;
" w: H: Q! [2 X6 \; B2 Svar newYDir;0 ]) `' [; [# i7 Z
2 }' S6 |% x4 g
function initializeBall() {; v' y2 \( |, h9 e
if (document.all) {# z. `) n! P: a/ E9 \" g* R$ G
xMax = document.body.clientWidth
, g9 a! f% g5 t+ P& R yMax = document.body.clientHeight5 L& W! \' P4 s* S% L r& C1 M% F
document.all("supertext").style.visibility = "visible";0 N* k; M& [8 c+ N! O2 T2 y
contentWidth=supertext.offsetWidth
2 Y* i% M& T2 y0 F$ X9 p$ ^ contentHeight=supertext.offsetHeight9 W8 j1 B4 P0 z$ s* _ L, z
}
+ M B5 F* U. M( @1 ~ else if (document.layers) {
5 I3 g+ H5 f/ g+ s$ d xMax = window.innerWidth;4 g2 k* ~6 l; |
yMax = window.innerHeight;
- y. |4 j( Q: f) N; _ contentWidth=document.supertext.document.width
. O" |- T1 ^2 ]; u contentHeight=document.supertext.document.height* U6 F" J, D$ ]! v9 V' H2 M/ ?. n
document.layers["supertext"].visibility = "show";) T) W& T. a) n5 H4 L' ?
}
. ~# W/ p" w$ R4 g9 O' } setTimeout('moveBall()',400);/ o" b* R5 E+ y2 Y9 E- n
if (hidetimer!='')2 a6 e. a9 B. q4 m
setTimeout("hidetext()",hidetimer)% G: D0 o( ]) f/ F
}/ W/ X* }, O+ N9 e
& I+ J/ e$ B" g
function moveBall() {
+ e8 A7 `! n0 q! b J9 {. L3 O if (superballRunning == true) {
# T; h8 K. ?3 [ calculatePosition();/ y6 C* [; Y# j% g; M
if (document.all) {: a# h$ X7 T; A ~% K c, {5 e j" T
document.all("supertext").style.left = xPos + document.body.scrollLeft;
" s+ B1 f( O9 D$ r- b# F document.all("supertext").style.top = yPos + document.body.scrollTop;
$ `6 ] e3 X. I0 m5 p, y. r }
, k; _- l1 u0 z& _* Y+ ]& V else if (document.layers) {1 J# W' v* G( K- J- m
document.layers["supertext"].left = xPos + pageXOffset;
) W$ {& v6 b8 m& x4 U document.layers["supertext"].top = yPos + pageYOffset;3 H6 F: Y. E, n9 _3 r+ Q/ `, ]9 ^$ q
}0 K+ @* w! @" x* T! f
animatetext=setTimeout('moveBall()',20);
% g& J# V# ^6 G) [3 h$ ^7 \+ k }3 b+ z8 z3 a# {+ U. ` O
}
3 p5 J( V3 r6 g! d! H
6 b% n3 {5 ]# Gfunction calculatePosition() {& P" m7 ?) S) Q/ ]7 I" H7 c- }
if (xDir == "right") {- j$ [+ [ T! _5 z( m S7 K
if (xPos > (xMax - contentWidth - BallSpeed)) {
: q, d- W- s6 w% _2 S* N: g8 M xDir = "left";% l: X# R! Y. L
}
* T; C" e: J* ? }
" _* R7 I2 p( X+ ?: u else if (xDir == "left") {
- e7 _" ]. H+ `. \ if (xPos < (0 + BallSpeed)) {
U5 Z. g& ]9 X& }+ @: D: l xDir = "right";0 y) _7 R# @% a6 O0 |/ c8 j
}
! h1 h6 @. V7 [ }
" a3 G c5 n$ }. p% j, W" c if (yDir == "down") {
+ A/ F& K' t7 w& b2 A6 s0 F if (yPos > (yMax - contentHeight - BallSpeed)) {
5 d% D# \1 C: u9 ~ yDir = "up";# u# M. s& F( }+ R
}
4 C. s9 O6 o g" C0 _0 o3 a }& ?# }/ q5 I; ~3 L: ?7 T* L
else if (yDir == "up") {
# z; R- a! D8 {! g" H/ P if (yPos < (0 + BallSpeed)) {
( `1 C1 I8 | o$ I& ]# P' u yDir = "down";
! v0 s$ J- Y9 ~' D }
, w8 c+ o; }4 N5 E }
& l k7 x0 ?8 ^4 C if (xDir == "right") {5 E3 N; B+ L: s+ C( s* j1 |
xPos = xPos + BallSpeed;
' e; R T" I9 n5 }7 l0 n }
- Z2 M" @" A1 M( e+ R4 T0 q6 O z else if (xDir == "left") {
5 s- y/ s2 W _: B" f xPos = xPos - BallSpeed;& k! A7 K. H6 b% M/ |; X8 d
}% i5 V( g7 L4 t: ^; C
else {
$ j1 m; Z; B7 d' ]# ?( D xPos = xPos;
" ?( R% H3 Y: s: N' \ }1 [. r& {' ~& `& H
if (yDir == "down") {& J8 _8 X: D D( C& h! i$ V. ~
yPos = yPos + BallSpeed;+ u3 r2 @2 {/ y, D' M7 E
}
- i6 S r2 _5 H5 a: ~ else if (yDir == "up") {
$ d9 y+ `8 b' D4 ?- _ N( X5 ]9 n yPos = yPos - BallSpeed;
2 t6 w0 k3 v. x* f; y, \7 j }
9 h. b7 X5 }. a* b' G else {! S0 m* ? }3 O$ b3 @
yPos = yPos; d9 N; X y% X# \9 K1 c$ q
}+ M7 Y' D3 r ~2 s
}0 t& c/ B0 R, e, m0 D. } H
1 A; `% ]" Z0 V& }, N3 C
function hidetext(){
0 F, ]3 x# T; R% I3 ?if (document.all)
3 y* B$ Z( C1 v, r( r7 x ]supertext.style.visibility="hidden"0 i$ f6 |4 \/ I5 ~' s
else if (document.layers)) D" P% A. R3 D8 s
document.supertext.visibility="hide"
- A O8 I7 v \) dclearTimeout(animatetext)1 p" Q, e/ |5 k" L0 a1 W- O0 E
}
. _$ P* u8 h0 D. @) L
& e5 r4 I* A: e& I: O: q7 _; @$ {if (document.all||document.layers){
4 f, J l' b/ {4 V7 R! w# Kdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')& R* A9 r# z9 j2 _5 b: _0 J, }, F7 W$ v
window.onload = initializeBall;
$ i- e+ R5 e6 a* wwindow.onresize = new Function("window.location.reload()");% U# v+ J, s( R1 T( n
}
( z1 r% _, v/ ^5 M9 t N" F8 N8 J- ~* a
</script> |
|