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

|
网页之不断弹射的文字-特效
<style type="text/css">5 n* C4 [& d c5 A
#supertext {
( d# R+ }$ g; @) T( E! tposition:absolute;/ n4 Y# l, |+ e2 \/ h6 p c
left:0;+ r- a" a m3 T: y+ g5 }
top:0;) O5 {: f) C0 p. ]9 P5 M$ F
visibility:hide;
% Y2 n2 [8 W8 i0 s$ z* mvisibility:hidden;
* m' t" N; e' @0 k1 q}3 M- f4 |: r5 I$ e+ m% h
</style>
$ {1 u' `: @9 h! e7 c) l# c" H<script language="JavaScript1.2">; A9 s; w+ q% _; I( z
<!-- 改变下的字体的大小。颜色-->
$ P' [0 D9 @; q/ k3 g9 [8 D* Y2 Tvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'0 |1 Z2 t. l% Z3 x+ H. G
var hidetimer='';
- F9 [7 \! N! k0 V<!-- 改变下的弹跳速度-->6 z9 u, x+ L9 f5 |
var BallSpeed = 20;
# a6 }" z( y% Z+ C$ P: y# Nvar contentWidth;
, _, B5 @, t; }. [var contentHeight;
/ y: Y# [+ E+ _var maxBallSpeed = 50;4 p( u5 G8 I6 j* l0 i
& I# S' `8 m3 R" G+ L8 R
/ I0 ~; v& o; _( e4 J0 O, H+ nvar xMax;" y, I% v& A! n4 d
var yMax;* }& n, w d5 O8 B$ V' ]
var xPos = 0;3 \8 F5 [6 y3 V8 N) N5 p
var yPos = 0;
8 n8 Q6 i/ E7 rvar xDir = 'right';
: a+ s' y# {6 g a* R. s% Uvar yDir = 'down';
) j2 d* I# }; k# Y# T n2 Avar superballRunning = true;; O; |7 Q7 P2 a0 F$ z. d
var tempBallSpeed;) U/ t, Q5 g: `9 q; j4 u! b1 f0 U, w* H
var currentBallSrc;
* f- ?0 A& L3 M; q$ W! |var newXDir;3 K/ e' n; m5 L3 i
var newYDir;1 a+ U3 A/ X9 o2 c% y8 s" J d
5 x8 J; m8 v+ ~& @% u# Q0 ~5 \$ e
function initializeBall() {
, |1 }! y8 |! A: [2 W if (document.all) {
3 g4 @, S7 z0 y, G+ t, F/ K* V; x- }/ [ xMax = document.body.clientWidth
4 U4 u! y3 [" j1 v* F/ f3 |7 n yMax = document.body.clientHeight
8 d/ s+ Y3 p3 M% }" { document.all("supertext").style.visibility = "visible";
6 y: R0 N# f Y9 s contentWidth=supertext.offsetWidth& L w& U, @4 H8 {# j
contentHeight=supertext.offsetHeight
2 p2 ?2 f9 }& F. L2 X4 b! I }% `) C1 I1 }0 {/ F
else if (document.layers) {
4 g$ w% ]: y: E; n; D+ R3 Q xMax = window.innerWidth;- U4 l' z" @" U% O
yMax = window.innerHeight;& n' X& F* L$ T. W' K3 z; e" q
contentWidth=document.supertext.document.width$ H! k: u1 z) L3 b
contentHeight=document.supertext.document.height
/ l& W( S1 R H4 L2 d" m/ l document.layers["supertext"].visibility = "show";' c, _/ w/ P8 G; E& a- f
}
7 ]# m+ J& _( g$ x4 v) T. n setTimeout('moveBall()',400);! H4 \! B) M5 w
if (hidetimer!='')# N( A' s5 L! E" n4 ^- M
setTimeout("hidetext()",hidetimer)
" U; Z0 _* _4 i0 l6 x( V }
" O9 A/ r4 I* [4 D( y
1 o' e3 U" f" ]) g6 B3 hfunction moveBall() {
5 ?$ k$ `' D c, \. Y6 l+ I if (superballRunning == true) {
' T/ V* R# `5 | calculatePosition();
! ?0 j: W3 H8 k8 G if (document.all) {
& [8 b1 s0 y1 U& h+ I/ n' i document.all("supertext").style.left = xPos + document.body.scrollLeft;
2 z- [0 L% z& ~5 v3 Q6 P document.all("supertext").style.top = yPos + document.body.scrollTop;
3 x. ^' E* e% z! ~ }& i. s/ }& _1 C
else if (document.layers) {
: V0 a b, d7 x0 d2 M document.layers["supertext"].left = xPos + pageXOffset;
) F$ ~- z& n! }# U document.layers["supertext"].top = yPos + pageYOffset;
6 T$ y( j& D1 h8 k+ ? }# K# o* z+ r. t3 ?. J& m0 o
animatetext=setTimeout('moveBall()',20);
! t6 v6 X( Z; L' W9 C: ^5 ?7 c% o }7 t+ l& ~- b2 r6 Q2 {
}* x% S/ Z [+ F r/ q2 ?
2 E2 y% m7 X: ~; a0 Qfunction calculatePosition() {. Y3 V A( [) G: W
if (xDir == "right") {# B$ Y: n7 ?" P4 f5 T
if (xPos > (xMax - contentWidth - BallSpeed)) {
" _1 x/ v" i; K$ U: H* } xDir = "left";0 z2 E- Z, M( a5 k/ D
}
% H5 M2 v8 r& i6 ^# v" n }
7 _+ I! m$ z0 } t else if (xDir == "left") {
9 ^- A* i+ n2 P! t4 I h/ G/ n if (xPos < (0 + BallSpeed)) {# {7 I+ Y; i2 ~$ U
xDir = "right";
' W* ?" }4 S: ~! Z' S. P }4 j4 \: \1 q1 M, O' E7 b ~
}: M& h0 \5 }% U/ a1 L6 N
if (yDir == "down") {
- q- @. l! D* Z if (yPos > (yMax - contentHeight - BallSpeed)) {. T, [* H# N$ ?! s5 g/ G; f
yDir = "up";
$ ^ W" }8 ]/ Y* F I }
+ U6 p2 F+ |1 K/ v }) [! @- a& C. V0 m2 P- q
else if (yDir == "up") {& L* M0 z" I+ c+ s5 k" O, w4 [
if (yPos < (0 + BallSpeed)) {2 l4 ^- Z# b) {! |$ q1 H
yDir = "down";7 F& t/ g3 A) N% q- I3 U
}3 @* t" U7 h# w/ ~
}
% K) s9 @6 Z& p/ b s. j, b k if (xDir == "right") {
% O' u6 `! X/ c- r; p+ p+ G xPos = xPos + BallSpeed;7 o' U7 ^6 S, \( Y- Y7 H
}% G6 j+ W4 W3 o. W, X; Q( c
else if (xDir == "left") {# p9 K- |) x2 z$ }4 b7 H0 y
xPos = xPos - BallSpeed;
. i7 J( B( o( g4 w0 s) ?1 X }
0 h9 q9 }* g) V; k+ r# Y else {
) g, Q7 \/ j8 Y% H, V1 d9 M xPos = xPos;
1 L* S4 l7 @# q8 N" [/ D8 _ }" e3 \. \; P/ @. v+ K
if (yDir == "down") {
/ c2 d: o8 b; O* @8 Q9 g yPos = yPos + BallSpeed;$ I: T" R! u% C; o* n4 V6 H# D
}) a9 D$ W( T0 n
else if (yDir == "up") {. ~0 O) Z; J; e4 Y& H
yPos = yPos - BallSpeed;5 L2 B" m( L6 m3 J& O: j
}6 T+ m' h. ?# s
else {& j! T1 ^1 Q+ c3 q& _- v
yPos = yPos;/ E8 v4 N, n' t1 V
}8 N, B" M6 W. a: ~! J
}3 M. r# O+ E$ P* g
0 @$ b$ [& ]% u8 z* Y5 D( T
function hidetext(){: V5 _& h8 E: t& s, k4 |
if (document.all) ]/ e6 V z$ w; {! c! X
supertext.style.visibility="hidden"
# F m6 l4 o% |else if (document.layers)( b' O, t1 y+ F5 i9 O5 _
document.supertext.visibility="hide"
( Y2 E9 ]7 H; C5 k& b" Q$ TclearTimeout(animatetext)$ d; e% \ |# K) x3 }8 F* C- v
}+ n3 h& k5 S) a
' z r% h, \& lif (document.all||document.layers){
& h9 o/ C& @1 Vdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 X* o. ]! S1 P. B3 F# b' Ewindow.onload = initializeBall;& } U# k- `/ M! z5 F
window.onresize = new Function("window.location.reload()");
1 f' R" y( v/ t" U% Q- r}
- U1 ?8 N2 s. y _9 L* B
" P' |. S% H! K q. u; I: l- D</script> |
|