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

|
网页之不断弹射的文字-特效
<style type="text/css">. I. _" Z6 S- A7 l
#supertext {
6 r8 C% ?9 ^5 O6 Pposition:absolute;
. V0 f9 W. `; P1 [left:0;
' a* h4 w% V" [& C- Ltop:0;2 f ?6 v4 g6 L
visibility:hide;; m9 i' c1 t$ l* `% H) H Q6 d! Z
visibility:hidden;
' K2 t4 M& _6 s# {1 I9 M( f: V}
* e0 F' T0 c; q: Y; R5 y</style>
) z+ i2 y7 f/ [' s* Z& O" i<script language="JavaScript1.2">
" ~. U% L9 D9 c' N" O<!-- 改变下的字体的大小。颜色-->
) h" x0 \: ~1 \; N, Zvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'8 A8 `) _' [3 v6 n1 K: u% ~& x
var hidetimer='';4 g$ `! g+ `% r: h7 g' c% e
<!-- 改变下的弹跳速度-->
- @! V, B5 k! Fvar BallSpeed = 20;
& g$ P+ O) H7 W+ f5 p0 b' l! r: Avar contentWidth;8 p7 \7 C& w3 M1 x
var contentHeight;: n2 K n" k* Y) U+ b6 Y
var maxBallSpeed = 50;
6 n; J0 R J" T4 N# a' |" i: L2 {# y
$ m( P/ s/ W& ~$ G6 L0 U# E3 n: q9 L$ e1 i, n
var xMax;0 }# p' }" ]& b: B" x, j
var yMax;
$ J! e; A" a& Fvar xPos = 0;
" _+ p, r; K9 X- i1 ^8 `: Hvar yPos = 0;
- Z( _' \; _* x6 _" o6 Lvar xDir = 'right';
9 M' t) V ]: u; l0 X! Lvar yDir = 'down';
4 e7 p! W5 Q8 x. Vvar superballRunning = true;
; ~: M" x3 h1 ~% t* e( c+ Rvar tempBallSpeed;
) X: H6 f, D( O' X/ r+ r |9 yvar currentBallSrc;# X" W* `2 n! R
var newXDir;0 s1 Q9 ?* T0 L; O( I! Z
var newYDir;( L; B1 H3 L+ G6 K' k2 R5 Z4 q% p6 X
0 _% B _* v4 V/ ~7 S! Pfunction initializeBall() {
( S: q3 T0 }- w6 q if (document.all) {& [8 V5 j2 @& T/ h" ^8 B$ ^8 c9 ]: m
xMax = document.body.clientWidth$ H+ s9 p% w# L7 d" ]. L
yMax = document.body.clientHeight8 L- X+ R2 l6 k
document.all("supertext").style.visibility = "visible";* W. f v2 J1 d2 r
contentWidth=supertext.offsetWidth3 j0 u' K* ]7 J* T! X" l
contentHeight=supertext.offsetHeight( Y! D1 \8 `' A2 @ Y' k6 w. k
}3 L* q. P2 h5 b1 m
else if (document.layers) {
: Q9 s+ o) j9 F4 H xMax = window.innerWidth;' Q7 T8 _. Y, W% T
yMax = window.innerHeight;4 c8 y# D4 I- x* H% A. s
contentWidth=document.supertext.document.width
+ A$ E K9 c) `+ D contentHeight=document.supertext.document.height
[! G* \$ N$ K$ d# E$ l7 M document.layers["supertext"].visibility = "show";
4 t. }/ p% l: c7 j. z# B* @$ K }
% D$ u* A7 F& r; [" M S setTimeout('moveBall()',400);
6 ]7 Q" ?- |, M0 F$ T if (hidetimer!='')0 E* G b* ?7 f" K: T
setTimeout("hidetext()",hidetimer)
$ N: ]7 O3 O# g/ O# V' r/ D% V }
% z- R# R: B P7 r, T- B X9 @9 _) ^" y" f5 z3 N( I
function moveBall() {
G m" F T. |7 n |# | if (superballRunning == true) {2 H, I `' Q( a4 r1 o' c
calculatePosition();& n! ?9 ~$ f/ N2 G3 B& C. O, K, y8 F
if (document.all) {
* A- d8 \- K# M5 [ document.all("supertext").style.left = xPos + document.body.scrollLeft;1 U w6 W$ ~5 O
document.all("supertext").style.top = yPos + document.body.scrollTop;4 M: o# K+ M& `" o Y7 j
}
3 m p$ P! w5 _ else if (document.layers) {6 }2 R4 y' z$ H! T7 e
document.layers["supertext"].left = xPos + pageXOffset;
$ y6 `6 c$ A2 l' L& |, u+ | document.layers["supertext"].top = yPos + pageYOffset;: [. _3 G, [6 |) ?! C. J
}
, ~1 i6 S6 ^' N# Y animatetext=setTimeout('moveBall()',20);: M9 `" ^7 C9 o K$ q k
}) i B2 z& g2 s& Y4 v$ v% k5 m: ?! C
}
- ]7 w/ e/ o, N8 e$ d6 Y/ C5 G j$ a" ]) e6 W& s0 o
function calculatePosition() {
5 U' v9 h; D8 i9 e% J- Y, ?. f+ H if (xDir == "right") {* G5 u( h: q9 H' W; _- u
if (xPos > (xMax - contentWidth - BallSpeed)) {' x9 {5 a0 K5 o; A, P9 H
xDir = "left";
' m1 b! ?/ M+ q$ m; C& L }
9 I7 `1 q5 j {9 [ }* Q% `: q! w5 q6 X+ _4 B
else if (xDir == "left") {! f3 R, k5 W7 q, R
if (xPos < (0 + BallSpeed)) {
! t- R7 Q2 S6 c9 m z xDir = "right";: R+ O9 o" O+ ^4 l m2 z
}3 O6 V5 O: c" s1 h' t
}
% X8 ?) S& Z( ?+ l if (yDir == "down") {6 y3 ]& L1 U, W- }& i9 u4 z$ P
if (yPos > (yMax - contentHeight - BallSpeed)) {
, r% ^. b+ h. [, L4 E% q8 f& V yDir = "up";5 H: ~+ c, a" `
}
9 @+ d& r6 x: h/ | }8 M- H2 r$ F/ f# I9 \
else if (yDir == "up") {' O. o4 Q; U/ }/ j- e; P( Q# g! Q
if (yPos < (0 + BallSpeed)) {
# n- \. r# n0 `/ f4 o yDir = "down";
$ S6 b+ ]3 U- `, z; N% m; F/ O q. Z }1 s" Z' y! a8 d5 s" {) w+ w/ z% B
}
. d; m1 M$ z) I# t if (xDir == "right") {
( i, N) j$ S' r4 e1 r6 h xPos = xPos + BallSpeed;
" l2 @# ]2 Z& l5 I a }! b9 D9 O/ @. a' q: h1 X% [
else if (xDir == "left") {
8 i, a8 i" F7 ~* L8 [ xPos = xPos - BallSpeed;
2 m3 k5 o- c* P) A/ n }) C4 M- f; Z- ?/ N
else {1 A. O" z6 W) o0 S
xPos = xPos;
1 }9 _8 \; |, a1 n/ ~7 V2 t }
: @: V; \0 Y) n# t if (yDir == "down") {, Z- y6 X, g6 U9 _
yPos = yPos + BallSpeed;; z& F1 Q) X4 Z6 I+ [: K$ Z9 ? X- L4 Y6 F
}$ Q" I8 U/ {; W2 g- R* K
else if (yDir == "up") {
% N# R& J L9 V% i yPos = yPos - BallSpeed;
" I# }. p# w/ }/ @' x% `$ z }
3 D$ N" M/ n; K else {' b7 Y1 T8 c& F$ i
yPos = yPos;
+ }* Q3 j- @- ~) p% ?2 G' r5 { }
* o) \; V" y) H; I3 K. x }
4 ?( d. Y/ k: Y# V: w8 d8 i0 S6 `
. R* n$ n* u; W$ i# A7 C2 Vfunction hidetext(){
5 a3 J7 W9 i% n+ @+ R! s+ eif (document.all)
. ~1 k8 V$ X% H7 t7 J0 T e) Wsupertext.style.visibility="hidden"
( V; k4 K h6 T4 e. }# `7 U$ felse if (document.layers)
! G5 l( T, n! Pdocument.supertext.visibility="hide"
1 E. x- h5 G; B9 `% d/ y' }0 ~7 JclearTimeout(animatetext)
7 b) ?, O5 L4 o+ B! G4 ~" {) R2 y}' N( Q6 m7 a$ }+ |& ?. G
# r9 `$ b; c. `. i6 j
if (document.all||document.layers){. J5 o# ?6 M R5 R4 ^( Q! n f
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
/ T& R( [9 [2 {" W3 u- M; hwindow.onload = initializeBall;
9 n0 _/ a' E l* nwindow.onresize = new Function("window.location.reload()");- Z& @& H; m8 M$ p4 M& @0 B+ ?0 F g
}" r- |% i) ]% K1 ~( R0 b
4 i% M5 m( i- G6 l4 E
</script> |
|