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

|
网页之不断弹射的文字-特效
<style type="text/css">
/ C( V$ B% a6 k" W6 R9 o5 F* v; o#supertext {
6 X* Y, y4 H4 f' a, `* {5 Iposition:absolute;
+ n! g+ k1 P! }" Sleft:0;+ `4 u. s# q0 r
top:0;3 Q$ H( t% p7 a* D1 T) I3 o
visibility:hide;, U, t4 P9 V$ N i
visibility:hidden;
" X! x3 u1 w. M k3 [; d p X}$ M+ g1 Y7 p) A$ \) ?
</style>: u. b/ ?2 C; t! H9 `" m: M
<script language="JavaScript1.2">
$ Y7 ?+ }7 ~3 Y( b* e, u* v<!-- 改变下的字体的大小。颜色-->
# u5 _! B& f) w* L/ \var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
' K% V2 j! u: h; Q( vvar hidetimer='';3 G, L6 j; i% i' r" q
<!-- 改变下的弹跳速度-->
; q o- i9 l7 s) B/ Wvar BallSpeed = 20;
$ k1 D$ @" U s. q& O e7 |2 Y4 @0 }; }var contentWidth;
. D. j8 g0 V# H( A" ^( vvar contentHeight;/ D; Z$ p/ }8 z& h& S0 L
var maxBallSpeed = 50;) V2 Z8 Z: r1 M
$ r' z; K( _3 ~9 C% p
% q& I' h- J0 k$ S% z; P. ~* S% ovar xMax;! N3 U; G- w& _2 {
var yMax;
& g$ Q3 |+ D* \. D3 avar xPos = 0;! R- }2 b0 B& {/ a6 c4 \
var yPos = 0;$ e! u! s( V1 B/ Y" z
var xDir = 'right';: I7 c' F1 K" e [6 W6 Z
var yDir = 'down';
% D4 @% Z; @/ x. X! T$ P) |var superballRunning = true;; A8 G) g) t7 A/ m9 k2 }) e% R9 i
var tempBallSpeed;5 x) w+ }4 n* i) o+ j% b8 y
var currentBallSrc;
7 [4 x0 q$ x0 Z8 k3 k2 wvar newXDir;7 i: o4 T1 b) ~0 \/ d
var newYDir;
8 e$ c1 x: p7 t! `6 Q3 C# A$ e! @! a/ f7 f
function initializeBall() {, Z a# l1 ?! Y4 n/ g" I
if (document.all) {, ?0 d, T6 H% L2 v
xMax = document.body.clientWidth
0 N( U/ i! W2 a& \ yMax = document.body.clientHeight
# z0 @( _! I8 Z8 f) ~9 i7 H1 R document.all("supertext").style.visibility = "visible";
# P$ G( E6 w* f% R3 K0 V/ M5 w( O/ Y contentWidth=supertext.offsetWidth7 y. I3 D* A i0 d( Y7 ~; m0 Z
contentHeight=supertext.offsetHeight+ Y$ |" f" S+ ]8 @( ~, i9 U I
}0 H0 ~7 o6 e6 I- s% w- c
else if (document.layers) {: I( |7 [5 r8 H( k+ p# e
xMax = window.innerWidth;
/ A% F0 u. k* n- s1 R yMax = window.innerHeight;2 m4 q: F( l/ n
contentWidth=document.supertext.document.width- J' Z8 B, F5 V" Q3 T
contentHeight=document.supertext.document.height$ U0 O6 I: x& {& y0 g0 K% i/ D
document.layers["supertext"].visibility = "show";
! v3 e5 p3 p6 \ }" j8 \% Q4 K. h* i. o2 J! j
setTimeout('moveBall()',400);
& N, V5 [# C3 F* k& O" M9 _& B if (hidetimer!='')
z2 q2 j4 j- T; w+ Y4 Y, X/ q: D setTimeout("hidetext()",hidetimer)
, L% W" k8 u7 \4 y+ K5 Q- \& N }; B: z) |4 C9 i3 `) z2 R# @
, l0 B# |/ L! I! }7 Q
function moveBall() {, k7 i: a) y" X! b4 d+ |
if (superballRunning == true) {
. }. B7 w3 o Q# W+ h calculatePosition();9 M- F7 x3 ~( w7 b7 ~8 S2 J9 u: }
if (document.all) {
2 Y3 N, x% [3 G$ ]5 b, b) F3 v document.all("supertext").style.left = xPos + document.body.scrollLeft;
! x# ?6 h9 \" q1 G document.all("supertext").style.top = yPos + document.body.scrollTop;
9 O( W5 d3 J" t( H0 |# L }- n3 [( c6 B" H" {1 G( O
else if (document.layers) {
* H) {! H% }4 C# r9 Y document.layers["supertext"].left = xPos + pageXOffset;5 H7 v6 K* C# h- _, d# h/ ]/ ?2 s
document.layers["supertext"].top = yPos + pageYOffset;
. K1 f- C; A) ]$ }8 y }8 z) a# F6 j7 X+ _# D2 u9 }/ Z7 e r$ N
animatetext=setTimeout('moveBall()',20);6 k6 Q5 w1 x0 H
}9 c/ H5 [3 ?4 I$ I
} k8 u) w4 d, l/ Q6 p: g3 B" o
6 a% l2 |9 P' J2 g. F) @
function calculatePosition() {" p# q v# W0 |
if (xDir == "right") {
4 ?0 g1 S" ?( j$ Y1 e if (xPos > (xMax - contentWidth - BallSpeed)) {! Y7 }/ W( n4 T5 h' J& z
xDir = "left";
2 X1 ]' u' q3 [; s" [$ c4 K. E }
" C' m5 k- H p }
u1 }. o4 M( v& M _ else if (xDir == "left") {
6 A. b' [9 n" f; X# Z2 E6 m4 p if (xPos < (0 + BallSpeed)) {
# f5 J7 ^2 y; s( h& F& z, k4 O xDir = "right";
% g! r& M" \; ?# x. i }
, ]8 v- I* ?7 V4 n0 x; F }/ S0 ]/ `# B& S$ K! u+ t9 k
if (yDir == "down") {
/ b0 D1 ^* e6 O if (yPos > (yMax - contentHeight - BallSpeed)) {0 S9 x T; }/ ?! B2 G
yDir = "up";
! e0 o r. p. Y A$ K4 L/ ] }/ |! |9 {& }, C, g$ P6 Z. v
}3 {& h* C6 }# {& V
else if (yDir == "up") {4 G6 y3 F% G$ i8 y
if (yPos < (0 + BallSpeed)) {
- A8 T1 ]1 u8 P; c yDir = "down";% w/ w3 D! i9 `% O0 x1 ]
}5 K( t0 ^2 T! d% u# s
}
: v! X/ [4 B7 ?* H$ S' S if (xDir == "right") {
5 e* H! s* J- Z: D6 m# d xPos = xPos + BallSpeed;: V z" N. I- g2 C
}0 b! c6 h, x+ [. u" u, d
else if (xDir == "left") {1 u# N) K2 s/ N" ]& {: X
xPos = xPos - BallSpeed;
# ^/ b+ r' Q( n$ J8 D* G; b) p/ m; D4 r }. d% O! j. X! I- \+ n% @. b
else {
% K' H7 ?) m) Y1 u) ~7 k) Y1 L xPos = xPos;
4 Y. r, h0 d! R6 B$ M6 V( I }: V3 J8 I4 L5 Q$ T1 r: e! n
if (yDir == "down") {
% u/ K# `& a2 Z' C( S! X yPos = yPos + BallSpeed;
6 ^1 ]9 S; `2 s) k n0 L2 U }$ G/ }* ?7 D. y1 k6 j7 T: @( \# H
else if (yDir == "up") {
3 o, q% i" h1 R% O yPos = yPos - BallSpeed;3 m" p. G' c# a3 o
}! _ a3 w8 R ~9 Y# Q% J5 m7 B
else {
5 B- ^# S( {, }6 ?) ` yPos = yPos;
( x U& X, X$ M: T- o" @: l9 j }" t& x9 f2 K6 u9 E
}4 Y* K& g8 e% m0 W/ q
0 H9 x: P) y: [function hidetext(){3 _! q% y. y8 d5 Y
if (document.all)
: N+ z9 P$ x! z: e! S& Nsupertext.style.visibility="hidden"$ [! l6 U) K4 C1 e
else if (document.layers)2 O) g( A9 G; p, z- n4 O
document.supertext.visibility="hide"
4 }0 W. O9 c) H# Z4 OclearTimeout(animatetext)' K- q H+ T2 W# ^9 i* m
}* Y* D2 C: R8 z( J- ?
- x! I; A: }. L( S* g+ E$ L% ^
if (document.all||document.layers){8 g. W3 J* C; W* Q6 j$ y
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')/ v% ]. A! \ m5 T
window.onload = initializeBall;# `: c$ n6 y2 y8 |" J
window.onresize = new Function("window.location.reload()");
2 x# A" _ g, u8 Y}
( [0 b7 F6 d# {2 u, J) R* ?1 f3 P8 U8 ?" ?' P" n4 ~$ W+ B+ m
</script> |
|