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

|
网页之不断弹射的文字-特效
<style type="text/css">
0 o& o! H) {! |# P7 }0 [#supertext {
: z" z4 |" t/ f( J, R2 u- ^position:absolute;& |7 k& Y a; ~- E( o+ a
left:0;. ]' {9 }* l0 Z9 B& Z3 P: q( `/ e
top:0;
5 [9 k! X5 H& D+ Z& X* g }visibility:hide;
7 M4 E/ p, H) x) i3 t, qvisibility:hidden;& c6 K2 b- b0 [2 K
}9 Y7 b8 ]' z& X. `; @
</style>
x- n4 l5 P2 t2 _) g<script language="JavaScript1.2">
: {" B1 s- [5 L9 J; o6 c+ _0 p<!-- 改变下的字体的大小。颜色-->
8 U3 ?; t/ C9 j! |' a! x) A7 zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
- @ o# {$ I1 m+ K4 cvar hidetimer='';
/ I+ _4 ~5 v; b$ h' P, ^7 ~; w<!-- 改变下的弹跳速度--> |. u4 v- @7 y S
var BallSpeed = 20;
9 _# e& g: q5 h* ^, Hvar contentWidth;
7 f, T% F5 x* Svar contentHeight;
% g6 w* k2 ~! z8 ?; k4 K: dvar maxBallSpeed = 50;5 l: I6 R7 \/ z1 o0 B& N
0 W& O7 L1 ?" v- t4 _
) i" K- G. d' H
var xMax;
! ?3 D# S) l9 N1 z7 wvar yMax;" M4 \ G5 X4 T1 M1 H
var xPos = 0;, F j# `) Q) R! @' S
var yPos = 0;
; f4 Q) Q* n. A) D: `, qvar xDir = 'right';3 m$ {8 Y% ], d" V
var yDir = 'down';/ x9 J G; n8 M
var superballRunning = true;1 m3 s2 {. t0 [) @; ?/ c! B
var tempBallSpeed;
6 }4 w S0 I5 g" I8 u. Rvar currentBallSrc;! v { `- l+ b" L* O+ `. B, p9 w
var newXDir;
; }. m" Y1 ~/ Q9 P" `1 Tvar newYDir;
' e# c( Z9 o& i3 s7 Q: I' C4 R+ I! p+ c4 m- |3 l( {* o$ \3 V
function initializeBall() {: G# p2 g- s3 C' O- Y
if (document.all) {, H& i/ Q. e0 d q1 O, y1 \
xMax = document.body.clientWidth
* e$ x* f; l t# i6 h9 h yMax = document.body.clientHeight
, v3 |9 V( u8 W document.all("supertext").style.visibility = "visible";8 |7 l2 F+ W3 j
contentWidth=supertext.offsetWidth' G) e; D% B+ X, h: O
contentHeight=supertext.offsetHeight
5 S) ^* g9 ]- K" f+ @8 p% Y+ ]5 b' V }
^. K( K7 l5 q else if (document.layers) {7 J; x* k- n; S' Z- D6 G9 n
xMax = window.innerWidth;& s. A% M0 E) p. Z4 a* V
yMax = window.innerHeight;4 N- G9 v n, Z
contentWidth=document.supertext.document.width+ b* B6 H2 C8 |. T
contentHeight=document.supertext.document.height2 {+ Q& N! _# n; e) P! ~
document.layers["supertext"].visibility = "show";
7 `8 F; w s( W# ~# Y# d0 ?2 i( r4 x. ~# g }
+ t9 q' s z% V9 T3 _( Q setTimeout('moveBall()',400);
, C2 T, X1 v5 P if (hidetimer!='')# w) P. L3 B# \6 \9 ~
setTimeout("hidetext()",hidetimer); J/ B4 D p1 O$ w& {, p
}6 w6 u! D5 q* ^. Z9 L
+ u8 @8 m1 R9 s6 e2 x$ q
function moveBall() {
: P6 A- c$ p |9 {. V, \$ f if (superballRunning == true) {; [5 j* C/ {3 ]8 a
calculatePosition();
( y; l2 i# A, a- H q if (document.all) {
) w8 m/ B# i0 u6 \2 O7 G) j document.all("supertext").style.left = xPos + document.body.scrollLeft;
- K' T7 Z* ^8 x. u+ H! b+ G! U1 q document.all("supertext").style.top = yPos + document.body.scrollTop;
% H3 {9 e6 F3 r' l. O( g5 V }
1 L2 L9 f; c: ~# ]- _/ Y; s ] else if (document.layers) {6 A! `3 ^1 S6 K0 |2 `2 g
document.layers["supertext"].left = xPos + pageXOffset;& `: j7 Z' c8 Z" Z. k
document.layers["supertext"].top = yPos + pageYOffset;
7 I/ m4 f2 ?) C* G7 n q, _ }
- A7 w6 G' E& Q7 F% a# P. n# ? animatetext=setTimeout('moveBall()',20);# `6 C% m2 \- X* a8 K3 s# O
}
( Q. _1 p; w: G/ q- X/ P5 N }
8 f4 c' x8 y" m' s! o. J4 F
( S6 Z6 a9 T. m |function calculatePosition() {
! [! r1 m, Y. t+ ~* \3 V if (xDir == "right") {; c2 C0 U- G y# N
if (xPos > (xMax - contentWidth - BallSpeed)) {; q7 h& g! p3 I4 Q5 ]% o. C! w
xDir = "left";
5 z! A4 t% A5 w. \( z }4 J8 p+ l7 i" \. Y0 L: R: |9 z
}
" n4 m1 i+ t$ W W2 B7 W else if (xDir == "left") {
4 ~. D$ v3 {: R if (xPos < (0 + BallSpeed)) {
9 l) y2 w; y- H6 @( P5 y xDir = "right";
. T8 i& p3 l/ o }% ~4 G" ]: W# P5 a9 W H" m* n
}# }( q* P$ e& q* D- `
if (yDir == "down") {
5 d- P9 w& h. Q3 ^; H& r7 r if (yPos > (yMax - contentHeight - BallSpeed)) {- \; {, x8 W8 L8 g$ u
yDir = "up";
* B9 C- i& y' C }
& {/ x9 Y9 S( J; n8 t }" _; n) e: `4 Y7 Q
else if (yDir == "up") {# o8 s% ^1 U( x, }# M0 D7 w
if (yPos < (0 + BallSpeed)) {6 y" H3 P( X0 H! V. g
yDir = "down";
3 g* y" q1 L8 b4 C$ F }. c+ \, k' v. T7 K
}$ n5 B# [( S# D) t4 M0 w
if (xDir == "right") {5 p3 _- f% H! V0 I$ X( |
xPos = xPos + BallSpeed;7 O! c% S3 `: j2 v) i5 W
}2 H- r) l& |0 ^1 x, @/ ]+ R
else if (xDir == "left") {
; k$ @" S/ a9 |+ o6 S3 v5 N" h xPos = xPos - BallSpeed;: w4 \5 @* l+ i
}/ \& t1 H2 r* b7 s6 O- I& Z7 h- o
else {9 u2 x; p% W) V# X+ f' E1 b
xPos = xPos;" c' e% V8 K2 v* U' [
}
+ ^, |0 |+ N" H6 W. t if (yDir == "down") {
4 }, n s+ n8 A" A7 d yPos = yPos + BallSpeed;
! i! E" `0 ^% B" S, f } l( c3 `/ \3 i) H. G0 ~3 _
else if (yDir == "up") {
* @. Y( z& c2 L8 N yPos = yPos - BallSpeed;
$ } z+ m; w& h7 `+ y' u9 r }
6 W$ ?3 m' C; P! ~0 j else {* d" Q, u# S7 t/ Z; Q' W% M, p& I# M
yPos = yPos;5 o) _4 g2 q6 q9 ^) L( x. ^
}( K7 P+ I. Q: }0 {, ]0 w
}
' l9 z0 N0 J" e2 M/ A- L) Q4 R( e6 u- M6 [2 t
function hidetext(){
/ s" F {0 I3 Z1 h6 Jif (document.all)' y" E, e4 v: r* H
supertext.style.visibility="hidden"
( s* s9 S/ x, zelse if (document.layers)
3 h% h: H0 l7 o( I% j5 o7 Vdocument.supertext.visibility="hide". q+ T& {. b4 Y6 L7 e, ^# @* ]
clearTimeout(animatetext)
1 G$ ?! A- u1 h$ g" U}# x9 N6 ^' k$ r/ q0 D% A" ~5 f$ Z
% {! W8 {8 M, C$ ~if (document.all||document.layers){
5 \( m% y! `1 w' V- b# U$ Ydocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')% l$ }. k3 p+ O0 ^
window.onload = initializeBall;
s- T" T7 ~( L6 c& |window.onresize = new Function("window.location.reload()");
7 D5 o% g: L7 V1 P, V! E}
. q7 p* b F7 d3 U* d( [7 S
. [( e& a6 |2 X. F! f7 o- k! z</script> |
|