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

|
网页之不断弹射的文字-特效
<style type="text/css">+ R$ V# y' J P/ G
#supertext {5 D$ U" |& r, u7 A
position:absolute;
) A% Y: f" w( |left:0;
5 i1 G0 B+ B9 g# T; |top:0;
/ V, f5 h* y2 `$ f: M }visibility:hide;( [+ F+ f! b/ J- z5 f! z
visibility:hidden;
2 ]7 ^2 ?8 X0 Q6 U9 s2 o' t2 B}
) q) [! n$ E5 K7 B( B8 c</style>! Q$ g& |9 R7 j$ Y( U4 E3 X
<script language="JavaScript1.2">5 Q# V& f0 k. d: p3 v0 d
<!-- 改变下的字体的大小。颜色-->! k% v5 _) r6 t
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
1 C7 \4 u e1 u+ b$ Fvar hidetimer='';
! y. k. [- M. l& y; w( T" v+ b* z<!-- 改变下的弹跳速度-->6 k3 K) `& L1 j: W$ D
var BallSpeed = 20;
% K [# ~, Q6 M7 Vvar contentWidth;: E. ~+ F. G' d. c) j4 ]% K
var contentHeight;
( M8 o' o! z# K: Y5 b' rvar maxBallSpeed = 50;
- M5 U# A7 V; A/ w) p2 Z# N. L
$ H) i ?- D7 X' E% i2 r# |
% N/ |9 D% P( i8 X$ Hvar xMax;
$ p& R$ b/ b) b6 V3 l0 S3 Pvar yMax;
7 {1 ?8 `& u) `- H+ g$ \& evar xPos = 0;
: [' {' e0 z' M( B3 Jvar yPos = 0;- I; q: ^7 ~% J1 f* a) p! n
var xDir = 'right';+ u' i7 \! |9 V6 A$ n$ \. U
var yDir = 'down';
5 y1 Z% f! Q- n9 q: b" Evar superballRunning = true;* r7 o6 z) i' @4 d
var tempBallSpeed; |0 h3 K& w, X& K
var currentBallSrc;
4 O1 s _9 @) xvar newXDir;
% u) ]! k$ d! C: l7 nvar newYDir;4 n0 J3 g# @( f! b7 T) ?6 o
7 g& F3 S) E8 {function initializeBall() {
( ]$ e: B- l; i! J4 m if (document.all) {" i+ R6 u' j! [6 B- a+ I
xMax = document.body.clientWidth# I% m" L# D$ x/ g/ `: A9 Z# Q& _
yMax = document.body.clientHeight. r: e# M- o, u/ ]
document.all("supertext").style.visibility = "visible";/ V4 F# j/ r5 ?7 W
contentWidth=supertext.offsetWidth
) L& V* [7 ` ]) X contentHeight=supertext.offsetHeight* d6 t: s g: R: k; {
}2 A: a; }5 r/ z6 p
else if (document.layers) {* ~& h3 L; f- U. I3 _1 V" q, v
xMax = window.innerWidth;: {+ B5 ~) a; R' c: a9 Y
yMax = window.innerHeight;6 d* o! i' d; _& |* R
contentWidth=document.supertext.document.width
1 m, v5 h! N d. F: U contentHeight=document.supertext.document.height
7 f" O1 }" }( u! I- p: r document.layers["supertext"].visibility = "show";
( \ c% w6 ] O V% F& E }
# E9 `: n' d& u- A; k- z# g setTimeout('moveBall()',400);
& c8 F1 q$ ]7 B0 X l6 h' g if (hidetimer!='')
0 q3 j3 b0 F- T8 y/ ` setTimeout("hidetext()",hidetimer)
0 X& H0 C" ]! N$ V, c6 l8 [ }( H9 k6 Q& u, n5 X0 i5 R
2 m- n& f _: Z9 n( M9 U+ |function moveBall() {
2 K6 d* N3 |9 l2 d v \ if (superballRunning == true) {
' t9 N+ z j$ d calculatePosition();) l$ U! [, Q% [( u1 ^% k
if (document.all) { ^, I- h# L7 p* S
document.all("supertext").style.left = xPos + document.body.scrollLeft;
, f/ {' N% L s document.all("supertext").style.top = yPos + document.body.scrollTop;
1 z+ f4 g9 @$ C9 Z5 n- v6 | }( G7 f7 y; r* n0 M c3 O0 q1 k
else if (document.layers) {
( l" z& K0 G' }* U; ~$ C, s9 Q document.layers["supertext"].left = xPos + pageXOffset;: O* h4 `3 L2 S3 l' \; `
document.layers["supertext"].top = yPos + pageYOffset;
& G+ u1 [1 T* D1 _4 t }. i/ H* G. m* D/ k% Q+ w$ K
animatetext=setTimeout('moveBall()',20);% \& C8 v; x6 f" A5 \% c2 e
}6 a5 I% n9 L: l" ^% s
}
6 `! A1 U. M+ H/ @$ A: S* }; C ^( l* G8 Y% k, k' Z3 B
function calculatePosition() {$ Z* _3 g6 x" L8 M( }
if (xDir == "right") {( H. u6 Q" |9 j
if (xPos > (xMax - contentWidth - BallSpeed)) {
9 S9 }( {1 C8 ?( `: M) P xDir = "left";
3 D; x/ d9 x9 F8 L# b1 y }
9 U" f& h1 @2 G" [& |0 Q3 f( S }* \% `& O4 r8 x9 Y9 X
else if (xDir == "left") {
* m# X' E# @$ V1 q+ ~4 @9 L4 G" s/ @ if (xPos < (0 + BallSpeed)) {" Y! `% ^2 t2 o" {
xDir = "right";
! R# G2 l+ Q; o$ N1 b. S+ ^ }
6 m# A6 r$ y8 O$ ?0 ` }3 F" w+ t& E9 n0 o3 q" d" u% [
if (yDir == "down") {- I3 B, e7 c" F* ]) J; P2 e& \
if (yPos > (yMax - contentHeight - BallSpeed)) {& K7 m! f. s! E- p4 L m4 _+ _
yDir = "up";
3 R/ S: S$ B2 ~# y% M4 d ^( Q }1 y! H( L; ^9 J1 I7 `- {0 k% u- ?
}
) ^/ A# n* ?* u6 d% n) f7 s& w7 c else if (yDir == "up") { R$ W1 w/ i. ?! H) }4 B
if (yPos < (0 + BallSpeed)) {0 U. m1 ?) e) u! n8 V/ V( f# Z
yDir = "down";% M j1 ?+ q9 p- z- M+ u, H
}' ]/ \$ G; m) @1 R" Q
}5 {( a" ?2 R& i8 ?; X( A, v
if (xDir == "right") {
# ~! O- \5 L$ A& v7 V xPos = xPos + BallSpeed;
& Y) O# e: z( w. p }
" Y! P* m- f% ]( q& `* v7 X else if (xDir == "left") {! r8 l+ w; I. Y9 A I2 A3 @
xPos = xPos - BallSpeed;
* ~, t( \+ s# Z }
; S% Q8 M. c2 e* f) m# l! ~ else {' ~5 m7 v: k) C) j7 {; P5 G5 c
xPos = xPos;
& w% S: B1 p! o& M# y, x }
, L t: k: f0 ^7 f0 R( \) w0 S if (yDir == "down") {
" D) w8 s' j# P2 C yPos = yPos + BallSpeed;
$ P4 v) F2 ^# P7 d" N6 w }
3 h- Z' i+ e# |! k3 k) w) j else if (yDir == "up") {. o/ I( n/ s, I
yPos = yPos - BallSpeed;
! p6 N" i2 N" q9 o; w }" q& t0 U* e$ f3 e$ H- C
else {
) k( |1 z( `/ ~ C- z( b( `6 \# e$ h yPos = yPos;
. Y" r$ w; E5 C3 w' T }. i4 |9 x: D( `5 R
}) }* S3 M @; M
/ o" ?# k2 h% ^! c) D% H0 L) A
function hidetext(){3 F. r4 e2 ?# Q9 M' f
if (document.all); c8 A) Y, G* C3 V1 x
supertext.style.visibility="hidden" {/ b! ^( Y% D7 _
else if (document.layers)
" H3 _: q' m) u- |4 V8 Ydocument.supertext.visibility="hide"3 t) @$ F1 r3 c! z& A
clearTimeout(animatetext)
5 B( o8 w" T" ?. I( q" Z o- j}
( P K- c- L1 j6 u! i6 X X2 l, b4 k* ]" A! p- Y
if (document.all||document.layers){
1 R; @5 u$ K# x$ I5 D1 H: T7 kdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>') @6 j6 ^5 }# n
window.onload = initializeBall;
* e" D9 A. x" B# cwindow.onresize = new Function("window.location.reload()");
# }+ ?5 y9 b: f# d}" _$ G1 F) V, _7 u5 l. q b
# x, x! v% T* a1 C5 X C' @
</script> |
|