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

|
网页之不断弹射的文字-特效
<style type="text/css">
$ e: k2 f9 p2 j3 ^#supertext {
% L: S9 L% Y" N X' Mposition:absolute;
% n7 [% d7 z1 N8 [left:0;9 A7 C0 {$ ^& w, {. g; N' B# A: ~
top:0;
5 h) T V6 o" c" ^3 Avisibility:hide;+ h$ t( e$ E) H. q e
visibility:hidden;3 H+ ~) Q. X& ?0 J! F- ?
}+ f3 S! v/ J4 g: K2 A5 H
</style>
8 T! B& k- ?7 ?' l" X ^6 y4 X- P<script language="JavaScript1.2">
Q' C. H$ ~: s. Q% V+ J4 r; v; D/ J<!-- 改变下的字体的大小。颜色-->" G f3 q! V9 d4 ~1 e
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( {9 r- i5 `# H% y5 vvar hidetimer='';
$ A7 d8 ^6 u. ?$ l; I<!-- 改变下的弹跳速度-->
* p+ h0 _. D1 M% Zvar BallSpeed = 20;- `! N* K" H3 \! W
var contentWidth; a1 B6 |( j9 `/ x! A
var contentHeight;
* e0 J$ `5 N% Y' V: ^var maxBallSpeed = 50;
3 }& B% x* ]+ }' ?6 N0 g7 |1 T) j. | Z8 W2 |
& E9 U3 I4 G5 Z: ovar xMax;
% [% r, C% |: J: W5 x7 A3 Gvar yMax;
# x* Y- X! c- Z+ W' X' _var xPos = 0;
9 a" a2 `! c; C" V/ ?/ M" u; dvar yPos = 0;
{5 O8 U1 v! v" Hvar xDir = 'right';
3 v/ a% d4 {- G; g5 i- s& R- a3 Nvar yDir = 'down';
1 W& O/ J/ H! a" bvar superballRunning = true;0 I! B* U2 s2 G7 t8 p1 I5 Y
var tempBallSpeed;
, o" T$ q% N A# n, U" ]7 W' I; Avar currentBallSrc;
! e+ x' h; r9 kvar newXDir;
3 t Q7 W2 a$ S Kvar newYDir;
7 {5 q) K6 D( Z1 R8 |; b; `8 ^/ M: ^! R
function initializeBall() {* ]( w2 `# m! u: k
if (document.all) {
1 i8 }/ ~+ D" D$ \2 G xMax = document.body.clientWidth% p) A+ l' ]6 Z! d& e c
yMax = document.body.clientHeight
) }- _4 L3 V- W5 _9 {% T document.all("supertext").style.visibility = "visible";5 v& u1 b- M4 a+ e* \
contentWidth=supertext.offsetWidth
1 |) e. l, j- S/ q contentHeight=supertext.offsetHeight0 X* w9 @' [# q) j: A) J. p
}
# q- x/ W9 O6 U4 K2 i8 r else if (document.layers) {
' A7 G! T8 f) r+ g7 h- T xMax = window.innerWidth;- U4 m5 |2 a: w# [
yMax = window.innerHeight; ^$ f4 N$ N. ~# v1 c1 K
contentWidth=document.supertext.document.width$ F) r* }2 ?) _; w' O3 S1 j
contentHeight=document.supertext.document.height
: z5 A2 N( A' x. s/ \ document.layers["supertext"].visibility = "show";
0 `% W# V7 X0 g6 L. n' _ }6 t# Y0 d, F1 p* v/ d X% ]
setTimeout('moveBall()',400);
0 c: t/ R8 `- p% O0 o" G5 ] if (hidetimer!='')
! O' f8 U1 d7 A( q+ j$ P5 g setTimeout("hidetext()",hidetimer)9 B% B M! B( T" {) U, b3 r9 Y
}
1 m3 ^' _; l. f4 Q7 y
' ]% N {5 I; z8 \6 }6 g+ ofunction moveBall() {
0 ]# i/ O$ P9 B% Y2 w5 n if (superballRunning == true) {
6 u# p1 n# [& w0 q8 d calculatePosition();
0 b2 d( t9 Q0 @' p; z if (document.all) {
7 S/ Y' A1 P5 ^! v document.all("supertext").style.left = xPos + document.body.scrollLeft;& j7 C; h5 f7 @# |- E
document.all("supertext").style.top = yPos + document.body.scrollTop;
/ A( M3 W2 f) M' s, p* h }8 q; n. ?) X) w5 r( @. l, r) ?. d
else if (document.layers) {
1 d0 [, l) e5 z document.layers["supertext"].left = xPos + pageXOffset;
; `8 {; V: F+ y; q% R; ~ document.layers["supertext"].top = yPos + pageYOffset;
) s7 b& X& u9 a0 U& |/ f3 C }" Y% Q& t- J# L" E, y
animatetext=setTimeout('moveBall()',20);
* E3 E$ R8 g/ p. _& g. p& p }
* i7 K/ `# x$ ]( D- {! l# u }2 J% e% Q r3 n3 T8 {
5 s1 p) ?( Z! t' b4 n6 M
function calculatePosition() {
6 F5 L, t& l* S& k6 @) W if (xDir == "right") { Q- `) K4 n, A
if (xPos > (xMax - contentWidth - BallSpeed)) {
. ~3 ^* f+ u) {9 T- P3 L xDir = "left";
% i9 s- @( n/ E* h1 u }
% q Y u5 P8 n/ B# w$ \% n }
3 [+ W) G# ^& f% \1 ^ else if (xDir == "left") {
7 D+ |( j8 H( H5 w( h( |- I6 b if (xPos < (0 + BallSpeed)) {
/ f; g8 N, c" q; G; Y4 E6 S xDir = "right";
5 Z) w; b. H6 O7 ]" I$ h }
0 B5 u( S; Z: M$ C9 S }& T. ?3 B. u4 A
if (yDir == "down") {
& E' S% @- M, W4 b5 k7 w7 m if (yPos > (yMax - contentHeight - BallSpeed)) {$ A& D. h( h: u
yDir = "up";4 D% c k4 T8 T1 `
}! [2 V! V; {" s$ _+ G
}
3 _+ g$ L( b7 \/ b else if (yDir == "up") {
. Q7 k" \! l) h8 W3 |2 Y if (yPos < (0 + BallSpeed)) {; `, v& ?/ q( h( a6 i o6 L9 i
yDir = "down";9 ?9 @% n" O& j; @( s
}4 ]# H1 k. ~0 `( U
}
& a' A' w/ |8 T if (xDir == "right") {
, W# |7 ^8 m& N xPos = xPos + BallSpeed;
; c$ [" @4 ^9 q* V3 p( Y2 f$ `: i v A }9 ?6 p0 b5 l5 W7 U; U t
else if (xDir == "left") {; B1 S6 _. C) M1 b2 U- y
xPos = xPos - BallSpeed;6 i* T5 a4 z; u* F2 r0 n
}
5 _ C/ Y( I9 T% O3 s6 {: a else {- \# Q- H$ f; ?6 J- W
xPos = xPos;. c. F7 s; C/ ^* N/ d
}
5 z; X5 p: n3 N. h8 y5 G# y if (yDir == "down") {
# W3 h& R1 e0 s! a; X yPos = yPos + BallSpeed;
$ u+ {! @" d3 U# G3 h3 C h( U }
2 X+ ?4 o" F4 ]: U/ S( A9 o! ? else if (yDir == "up") { N! \$ y ? K9 `: c
yPos = yPos - BallSpeed;
9 M3 K; z; r7 ~3 W; \! _8 @2 J& v! [ }! {3 J( ^' `( P$ \
else {
- g) X4 _' K+ {- z+ M+ m* ? yPos = yPos;
1 ], G; Y' m1 E6 m. T4 p+ Q }
3 b- _7 o6 B8 p3 ]$ R5 o1 E }8 }3 I" h: J9 C- \4 ~/ u
1 V$ U" L% M# ?4 _9 p0 R% o
function hidetext(){
: }$ R2 Z: R! d1 {/ ?if (document.all)
f" g" }$ Y7 J4 R# d" p# jsupertext.style.visibility="hidden"
! W; W2 w% u7 M4 Eelse if (document.layers)
; w- W5 A! r. [' X q% u9 @document.supertext.visibility="hide"
$ _% g* L6 @: q6 f8 G$ v2 {8 MclearTimeout(animatetext)
5 l: H1 Y& ~2 H$ d% v5 \. P- m% V}
& I" z0 D# m2 Q: g n, [- Y- v4 x
) o* n* N4 S" z. r Eif (document.all||document.layers){) W+ D- Q- R; L) n0 m
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'): Y {6 B, x8 k$ q4 W1 X6 A
window.onload = initializeBall;
3 H+ B) E5 ?$ `2 G- ywindow.onresize = new Function("window.location.reload()");" @; W/ |6 d4 Y6 N. O6 ^
}
. m3 [0 P' R _! S8 m$ ]9 K- @; \$ c$ t, Q9 }) ~
</script> |
|