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

|
网页之不断弹射的文字-特效
<style type="text/css">. P- K& L6 E; x( l$ x
#supertext {3 w: i8 `! d6 m; b0 I
position:absolute;
4 |( B5 A" g7 q8 {left:0;
* j' y8 b7 {! B) ctop:0;1 T% @' @; L6 {
visibility:hide;2 @: t4 N2 Z2 E# d
visibility:hidden;
2 ?, B& `3 |* P9 P}2 G3 K1 t( ~$ b
</style>7 P$ Y* y: P3 s8 O& c d( Y
<script language="JavaScript1.2">. l) S: L/ U5 Z0 a8 z. Q$ F g
<!-- 改变下的字体的大小。颜色-->
$ o4 J8 E. ~5 ?0 r) Y- h6 vvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'$ Y3 g i, d |! ]3 T* f
var hidetimer='';
) ?7 K# S" x2 g: D% a# O<!-- 改变下的弹跳速度-->) X. y5 b$ i/ J' P1 {2 W2 A
var BallSpeed = 20;
" s3 E; h" x+ P* g; s1 o% r# lvar contentWidth;: Q% X5 q5 V% S [0 U4 X& w2 ?
var contentHeight;
* N8 \9 ~% ^! K n& @5 x4 c. Hvar maxBallSpeed = 50;5 s- D# S, ]- A) i* }7 E
* r# L5 ^- d& z; [& O" Z
" \/ T# f% T" W3 o8 @, _var xMax;
* ?- ~6 p+ w: ]0 V6 `var yMax;
; p/ P# _- V3 G1 Yvar xPos = 0;7 \. F% a* N: Z; f, `
var yPos = 0;6 I* s+ [! I/ }3 K) u
var xDir = 'right';
( D0 R/ H( T6 S1 k. e8 i4 t6 d0 t2 t: ^$ Yvar yDir = 'down';
# x2 W5 O0 e; v/ Y: nvar superballRunning = true;9 q6 A7 ~% e X
var tempBallSpeed;
4 v D, I$ x2 R4 Bvar currentBallSrc;
; h! d4 Z$ _% B8 T, i7 h @ Vvar newXDir;3 i t& s! _/ W% q5 d! n( `- a
var newYDir;
9 `9 @; m! |6 t) _0 V5 q
& K! T- Y/ Z* I6 J: k; ^/ V4 d% nfunction initializeBall() {0 P& y# o" X: x) v
if (document.all) {; P- |# V+ [1 x# P5 O; ^
xMax = document.body.clientWidth
% f, s, B6 r8 q( D" C0 s yMax = document.body.clientHeight, z" O" V) L; t1 k: ?* R4 h
document.all("supertext").style.visibility = "visible";
6 j* d1 j2 Y+ \* p contentWidth=supertext.offsetWidth# A9 T" D' G' L8 l C' _, w
contentHeight=supertext.offsetHeight! G, `' Z+ j9 C/ `# y4 E' a2 q$ X5 \' g
}$ l/ d, s; o9 k( K1 T% E9 v# I3 b
else if (document.layers) {/ {+ C. D I7 m/ X8 @
xMax = window.innerWidth;
8 N; i3 N6 @, Z yMax = window.innerHeight;
2 `+ D( ]) N: e, ^0 F contentWidth=document.supertext.document.width
- X8 t4 L) D& O, |( L contentHeight=document.supertext.document.height
" E1 ~3 ^# X2 G/ J. T( j2 u: \ document.layers["supertext"].visibility = "show";
# R! O" p- r8 K6 j4 y# ]. w# E- \3 b }
\6 r. I5 P2 ~ setTimeout('moveBall()',400);5 c9 Z4 s# Q! f. w& e, k
if (hidetimer!='')
. K( `+ h( _6 O setTimeout("hidetext()",hidetimer)) ^3 S6 u1 w; b) D9 { v
}
0 k0 Z5 K% n2 d) _7 C/ m, W7 H g$ [& } D! W% h
function moveBall() {
8 ]$ ?' z7 C8 [% e if (superballRunning == true) {
$ i/ a% v1 h0 B8 `: B6 `& l calculatePosition();
0 g4 P. i- k W& W3 X8 y if (document.all) {
3 X- @: i) J$ E document.all("supertext").style.left = xPos + document.body.scrollLeft;4 Y s9 o0 @9 }0 S$ K. N) d. U
document.all("supertext").style.top = yPos + document.body.scrollTop;
" j/ U% M. s8 W0 n }
/ g' J# m2 P- p8 v else if (document.layers) {
( D, C* k* G) K& q! O document.layers["supertext"].left = xPos + pageXOffset;' I/ t5 s2 L' {/ R7 X/ X* l
document.layers["supertext"].top = yPos + pageYOffset;
) P/ f1 t* m8 U3 u. V8 L1 e }) E/ g3 |! Z- S$ g- s; d) m
animatetext=setTimeout('moveBall()',20);+ _% ]" @2 g, P+ W2 C: }2 D; g
}
+ l% G% @ [/ v/ o }
0 G! G$ S" G$ S) W/ O+ U: J$ p5 s; `1 B& e6 I9 o7 V) B' m
function calculatePosition() {
; L8 n- M7 y: e9 ` if (xDir == "right") {
7 {8 k! Z" v/ s1 i" D1 m: | if (xPos > (xMax - contentWidth - BallSpeed)) {
i5 h$ P/ E# M& ]; u V# g* x7 C3 _ xDir = "left";, `+ s' l" ?5 `, \* [4 J9 p
}" A7 G" Z0 P& H
}
0 G; H" F7 U: p9 \ y else if (xDir == "left") {: X$ m' t8 I& g0 E) ^8 Z/ g% Q
if (xPos < (0 + BallSpeed)) {1 M# Q" Z! n& d2 T8 G; l7 `* z
xDir = "right";
2 y) a5 G. x/ r: s }
" k, G" s1 N& ~+ F; c3 B2 O }' \5 B9 W* B3 M3 v1 h
if (yDir == "down") {# [" q- U! \# Q6 k
if (yPos > (yMax - contentHeight - BallSpeed)) {
: J% T* P! N* ?) c6 H yDir = "up";
6 l& a. J5 ~% l1 `: ^6 W }8 y; f4 @- `' N& y" E
}, j2 B- N6 L; V
else if (yDir == "up") {
2 q, I# {+ o( V3 j `; k- h1 H if (yPos < (0 + BallSpeed)) {* ^9 N0 \0 p4 ^
yDir = "down";/ K- E" _9 E5 V- m
}" w6 h' h3 S5 h
}" c- Q% ~2 Z# l |% r
if (xDir == "right") {
( _6 @1 S. z( P xPos = xPos + BallSpeed;
$ S3 S0 M( w* e$ V& g }
! v! X( N+ I0 E3 I else if (xDir == "left") {
5 c! \: f% M0 A( T% I xPos = xPos - BallSpeed;
% g! S, N5 X/ n# I1 G/ i6 ] }
2 x" ~# x- M9 K6 g! `% C) T else {& c. c; v5 m3 a# K9 K% c0 p) g5 O
xPos = xPos;4 w6 f) ?) K8 E) a5 {
}4 Z- T9 e+ ^1 C) C
if (yDir == "down") {
7 v# z" y) l$ g6 S% h8 Z yPos = yPos + BallSpeed;
9 g& U: q- D% a/ r }
t% \) L K/ r3 A0 K: v- s1 i% G else if (yDir == "up") {& }5 [3 W9 g" \
yPos = yPos - BallSpeed;. T' \. c0 `# x6 ~: Z
}5 m* E. v; T3 g, @
else {2 g- W3 A) h4 A z5 R" V* y8 [
yPos = yPos;; v* W+ ^6 F7 a% y* b" j0 ^( b
}
8 v0 ~; |& J5 J6 r+ t* U }% o N. D" Y8 Z( E7 I
- J4 `( u7 j# a$ ^( s
function hidetext(){$ Q/ _* w0 e0 V. ?3 V
if (document.all)9 {! O4 V: j3 s* l) J5 s, Z8 J7 n
supertext.style.visibility="hidden": K, u8 R- w8 E9 f! _
else if (document.layers)
" X1 G: g6 L3 k' s! @) g( Fdocument.supertext.visibility="hide": l/ C+ F* @/ a* N
clearTimeout(animatetext)
! t6 j, N- y. E& l! W0 U$ x}9 A f) {* i1 t9 F4 g# N# ]$ Q* }
& ]7 t% j8 U$ k8 u+ F3 N! Mif (document.all||document.layers){
1 o4 V% S6 y$ b# M) Cdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')2 \+ c2 [# b1 V3 B0 ]0 Y/ K- E
window.onload = initializeBall;/ y) G( X6 e5 B9 D: X; L* {9 u
window.onresize = new Function("window.location.reload()");$ d& Y' p1 ?0 B9 j* \5 c
}
9 f/ A1 \6 L# E3 X- y! q; Z+ R0 ^" D' ?! J! [- y
</script> |
|