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

|
网页之不断弹射的文字-特效
<style type="text/css">
% u2 |& ^/ O2 ~' z6 G8 u#supertext {
, @" W! W2 i9 V- S# d0 g* N/ o+ s2 Jposition:absolute;
( p& r* H( F8 w* L U% jleft:0;
! l1 n8 W( e2 N( N$ e0 j" Z: e# Xtop:0;+ d. K7 V; o, x1 l2 d) z
visibility:hide;. L7 R! w% n0 Y/ n$ y: q6 K
visibility:hidden;
) s) U, X$ y0 D9 w% y}
; j8 R U! ]9 s$ M</style>- a1 t$ d$ B8 O! D1 ?8 N' K
<script language="JavaScript1.2">1 t4 ^" W5 r8 J H9 K# a+ Z/ o
<!-- 改变下的字体的大小。颜色-->. @4 ?! P1 A* B9 w# Q
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
/ _; L9 R& }: hvar hidetimer='';
9 o/ f. I9 y3 I* \& M+ i4 w<!-- 改变下的弹跳速度-->
' y* E4 j9 M" q5 b7 r% Gvar BallSpeed = 20;
* l3 ]9 k) O# R# k& K9 B8 N& [/ }var contentWidth;6 ~) R6 n% o9 D3 j8 g0 L
var contentHeight;) U6 h) {) }! D/ b' a
var maxBallSpeed = 50;
# d6 V. u! w8 w q" u3 H/ t8 q3 X$ A. g. e7 u
6 j* A. B& n5 \+ a$ [/ h
var xMax; g) U2 t. Y/ \+ ^
var yMax;8 { s y; _, d4 V1 Y
var xPos = 0;: Z6 S$ ]+ `/ } ^5 G, c
var yPos = 0;' r: ~5 t# c( B
var xDir = 'right';
5 X G; ^9 h* ]% p3 `var yDir = 'down';. @7 {# G7 A6 u0 _% K5 o# ~2 }4 S
var superballRunning = true;7 A; x6 U; }% b0 H7 k% U
var tempBallSpeed;
" M# f# [. V/ rvar currentBallSrc;
' |4 ^; i/ I; \3 z; O0 Uvar newXDir;
\/ a5 U! G6 Fvar newYDir;
n7 y0 N/ g: v& D+ E4 M% {* f9 ]. v. z) e
function initializeBall() {
1 |# Z2 d5 @' |, c* T1 T0 ?9 S if (document.all) {
8 G/ K# \9 c; g$ J z- _ xMax = document.body.clientWidth3 h. G* F( v3 Z& x
yMax = document.body.clientHeight3 O* Y4 d+ Z1 P4 D: v8 f! a- O
document.all("supertext").style.visibility = "visible";& `, J) G3 p3 k x4 l# K
contentWidth=supertext.offsetWidth& m, e9 M7 I, m
contentHeight=supertext.offsetHeight
+ s/ y5 T7 s. C7 c/ v7 j r }
4 Y* F. H2 g$ t: i( Y else if (document.layers) {2 L t8 g- [* ], u( |- c3 G Y
xMax = window.innerWidth;
0 l" g) J9 G+ @" @2 q- k; y yMax = window.innerHeight;4 ^* {/ Q, E Z8 W: l
contentWidth=document.supertext.document.width
2 l! J8 {, O% U contentHeight=document.supertext.document.height, p, W% N1 s# I! I
document.layers["supertext"].visibility = "show";
a' T9 `, q$ I2 G+ o }
/ G# s0 @# z1 h setTimeout('moveBall()',400);& K8 A" i( L9 b5 t3 ]/ C, { L
if (hidetimer!=''). s' \6 o* x! o* F1 Q
setTimeout("hidetext()",hidetimer)
0 Y9 K5 y7 e9 |( `. k; Q% t! T }* { U* {/ {% u; ^* Y3 Z: h1 r
1 ]' q& P& z2 {: Q6 |6 V
function moveBall() {3 r6 G# k1 `! |5 x5 m4 ]4 U
if (superballRunning == true) {( o4 Y- w! x2 W+ T
calculatePosition();$ u" N! |/ a0 _3 D, M8 X* f
if (document.all) {) q$ {8 s7 D/ s- J( q" h7 v
document.all("supertext").style.left = xPos + document.body.scrollLeft;
0 [! n, j% w& v ?3 T: |6 y. B. C document.all("supertext").style.top = yPos + document.body.scrollTop;6 ^* r: r" d! ~, O! }6 o
}$ Q) c" `) U% p& v! d
else if (document.layers) {
% Q/ P+ Z- P! _: X4 F# Y document.layers["supertext"].left = xPos + pageXOffset;
( P7 g, G; e- n; M: [* _7 p document.layers["supertext"].top = yPos + pageYOffset;
7 x+ f; }( J0 d7 s$ f; E }8 \, F& q& Y% f4 D
animatetext=setTimeout('moveBall()',20);8 C' S6 d; J' {' c& o
}
+ V0 D( V/ m( C }
D( W; E- p A$ x+ G3 T% g0 M# z
0 U9 T' [6 |' z1 A0 I9 ~" L, [( S, Kfunction calculatePosition() {8 {- Q( C1 W. H/ Q" I/ F& ]9 n
if (xDir == "right") {7 R# {( w- b" N$ \( ?( ]
if (xPos > (xMax - contentWidth - BallSpeed)) {
" g: h/ x6 m5 j, {& L2 c7 X xDir = "left";
6 l# |! K+ P) k# v1 R }9 D5 w! \# k" p5 m
}
6 y$ v* V c# d1 K8 W/ i# K else if (xDir == "left") {9 q; h( U/ e0 `0 x6 z
if (xPos < (0 + BallSpeed)) {
* m7 M2 ?3 U% L! c xDir = "right";- p+ A, l* ~& S4 g' w
}, {1 u9 q9 s; ]+ V! D r/ Z
}7 n9 u2 i( u% e# J1 A% T5 S
if (yDir == "down") {
6 l6 U) w! W. G6 r. ? if (yPos > (yMax - contentHeight - BallSpeed)) {: f+ l' Z: n: @; k) P) c+ }9 t$ y
yDir = "up";
! S( c( P. f/ K9 E$ a# k& B7 c } s X/ z8 H5 Y8 }# o) r9 K
}6 @9 O3 o2 a+ H3 E
else if (yDir == "up") {
0 I9 X* y' p6 @6 ?; @6 o if (yPos < (0 + BallSpeed)) {
- D) k# H, l; U yDir = "down";
/ I/ N: e+ h/ ^8 K( o- m* u) I0 n" z }) v" `9 r; |: R6 ]3 W
}
. m; [3 x+ W0 B0 P) W if (xDir == "right") {% q& g* I: ~; ]2 f+ K
xPos = xPos + BallSpeed;% Z, Z4 E1 i8 f6 s" q
}5 j4 W3 C1 g" M
else if (xDir == "left") {
' V# L7 z+ i. M# R xPos = xPos - BallSpeed;
2 q5 T4 T* S% W& w }
$ g0 z0 Z& L3 t else {. P3 Z2 O6 }: z: ~1 H* K
xPos = xPos;
( v6 ^* u+ R. a+ ? }
3 u! S) c- p3 a) J# }6 U+ T if (yDir == "down") {
6 X4 u1 g0 D1 l' S3 f( X% Q1 K: U yPos = yPos + BallSpeed;
9 H8 I& n$ n7 Q# ^7 ?) o6 T }1 T4 \: S) V w5 a9 {8 q
else if (yDir == "up") {- b6 d9 \. E( t1 Q$ e6 z7 t! C
yPos = yPos - BallSpeed;
3 \6 r6 `5 E9 a5 F }
$ Q. W9 x* f+ o( l. [ I' e else {
* v+ w. b+ v6 u5 ?- R" K yPos = yPos;. a1 P6 R5 o" ]) V# l
}" ?: P% }) @, J" x) Z- ^
}; d [7 ~2 n+ I* R5 f! l0 A- I
! o- e5 @6 l( u$ R+ O8 R7 }
function hidetext(){
, n2 }( @! }# X) ~if (document.all)" Y( w$ }0 ]& S
supertext.style.visibility="hidden"8 u, W- }( b) \
else if (document.layers) c/ Z+ c5 r; D5 b
document.supertext.visibility="hide"
3 X0 L8 K9 T8 \( b' l/ b% ?clearTimeout(animatetext)
3 i% u o# Q6 C+ ~}
4 I: X$ O* @ f8 T M, m9 w9 V9 P1 ]7 E% }
if (document.all||document.layers){
, C- F' R$ ?. m% S* [document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')% ]' m1 Q/ g# }: u( L" Z/ c; f
window.onload = initializeBall;
* m2 X6 |2 F6 w0 @4 x0 a4 pwindow.onresize = new Function("window.location.reload()");
* J+ a& y. i! b# C1 F( H. v}
# l& C, O4 G" y; q% R* m4 y `* v+ }
</script> |
|