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

|
网页之不断弹射的文字-特效
<style type="text/css">; C# W7 U: s9 @ D3 G3 X0 l w/ ~
#supertext {
/ ]1 ]/ K, M2 ^" B# `7 Y. [position:absolute;. I' h( I3 U' J5 v/ o6 V
left:0;) n( N: o8 m5 o( \
top:0;6 j H! I- L1 ^1 b, G; ?7 a
visibility:hide;
* I% I* P1 |5 C9 ]# @visibility:hidden;
: Z- _6 l- b( Y8 ?}
* V9 B# i9 o* r+ h& G7 c, {8 y</style>
. Q/ G1 z( v/ W9 K" y1 e<script language="JavaScript1.2">4 L5 N @5 B/ L5 z Q+ @
<!-- 改变下的字体的大小。颜色-->
# ~+ z8 Y" V0 [& [) `var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
0 X& j2 ^* o* H9 N4 S1 t5 Q. mvar hidetimer='';, z3 a! v. A/ H2 T# U& o+ n
<!-- 改变下的弹跳速度-->
: W( m Z6 ?6 N# |, _! l0 I0 Avar BallSpeed = 20;
* ^( k% ]0 A1 j( J- p- Yvar contentWidth;6 m& y+ [7 n4 q
var contentHeight;2 t4 m# \* l, u+ w
var maxBallSpeed = 50;1 w! H" f. l" i- h9 j
4 U _2 s9 |! O; K F5 d$ y$ S) R
var xMax;& C) L$ V" R" G8 }* b
var yMax;( f3 z- s8 W% M% Z; x
var xPos = 0;6 s- Q. }+ n: o2 h
var yPos = 0;
; t$ S* B8 G" O8 `var xDir = 'right';
$ l2 {* m3 D7 x/ q2 uvar yDir = 'down';3 T4 I! k% x C$ t h3 q
var superballRunning = true;) e) a: O+ A, ^& j" \. x
var tempBallSpeed;
/ C# k3 N1 ? x7 W( [# c9 Dvar currentBallSrc;5 L. ?. W. t% w a6 e, D
var newXDir;
7 X! `( l$ v) w# |+ P* ~var newYDir;
1 L3 b& m# W* b0 A
" P- o2 x! u/ Q. W* C; Hfunction initializeBall() {
$ {7 _1 t/ B/ L: t7 r) P if (document.all) {
6 [) \! T( I g xMax = document.body.clientWidth
# U, _4 o* `* O& l yMax = document.body.clientHeight! C8 V0 f+ U4 U$ j
document.all("supertext").style.visibility = "visible";
5 k# h, K v+ T contentWidth=supertext.offsetWidth
$ ~6 N8 @" U. h0 n+ X; p3 `. ~6 \9 [ contentHeight=supertext.offsetHeight
' A# Q# @0 O4 z9 Q }7 K2 Y# y7 k d* c+ \7 W- M
else if (document.layers) {- I; p& A' R, S k6 R
xMax = window.innerWidth;( o% m: ?" C4 @7 A- y. ?( w
yMax = window.innerHeight;' j* i8 T: Y- p! \3 m7 O2 @3 U. S( g
contentWidth=document.supertext.document.width
! Y; s$ M) n Z5 j contentHeight=document.supertext.document.height0 C8 D& o0 X2 K% E% J* @
document.layers["supertext"].visibility = "show";
; [) h$ c6 O! M }% U* ]: N I. R# `! e
setTimeout('moveBall()',400);2 C! g6 w0 m3 l; E- t+ [
if (hidetimer!='')
/ ~. d. }2 q0 C$ O% U4 P setTimeout("hidetext()",hidetimer)( M: U5 R! e& ]; W; z, x& W
}4 p$ N) u( J% t# ~( l) g
& m" x- E! m$ Q0 Hfunction moveBall() {! w/ g% K6 {1 I# X. s& \
if (superballRunning == true) {& N4 I# Z1 \1 r! g/ l1 t; ~; \
calculatePosition();. u- i5 P5 @" h
if (document.all) {
2 h$ j; ^, d% p8 a8 ^" y document.all("supertext").style.left = xPos + document.body.scrollLeft;2 I! ^ F2 u8 g0 q* _3 o
document.all("supertext").style.top = yPos + document.body.scrollTop;
8 ^( Q q5 ?: O0 O O4 B ] }
% _* Z3 _" l! D; R. X* w else if (document.layers) {: H( k$ B- `" P
document.layers["supertext"].left = xPos + pageXOffset;
( X) M7 _' @) n6 u3 e document.layers["supertext"].top = yPos + pageYOffset;1 Y3 o; w. y& i- \3 [$ e& i
}$ w9 ?, K# L: l% n- E- ^
animatetext=setTimeout('moveBall()',20);# h" D5 y1 b3 p, B% ]
}# f) q/ {9 G) V" J) Y
}$ v$ @+ j: Q V& P6 m* K3 d. n
# z3 n. C. D1 U! L" M/ xfunction calculatePosition() {
3 H1 ^! {8 O' Z if (xDir == "right") {- i( K) S1 b2 x" h! `
if (xPos > (xMax - contentWidth - BallSpeed)) {% N1 |6 u3 E4 Q0 @+ G0 u) x9 q3 R
xDir = "left";5 m; V5 V6 T9 w3 M9 h ^
}
3 r5 O7 A) w$ S, g1 G8 z# F; r }2 W, S1 D2 R7 u# J8 `, w# K3 _' Q
else if (xDir == "left") {& V$ c8 x; Y, I- n. ?' N
if (xPos < (0 + BallSpeed)) {0 \0 @9 D) g0 N- v& u1 U
xDir = "right";
: b2 ~- R7 a- M }
4 ~" ~, O" q8 s/ m7 i0 U' P- m3 D }5 s S$ M% t' G9 y3 r' u
if (yDir == "down") {2 _7 R5 N0 R! |" m- F# V8 y
if (yPos > (yMax - contentHeight - BallSpeed)) {. t. u, [; |& s
yDir = "up";
8 M1 u' i/ k C9 j* v' J3 ?+ M+ W }7 k# s# q- |% R
}
. P6 Y8 {" g- d: h9 r8 ~ else if (yDir == "up") {
* h8 q& x6 t& ?6 o' Q if (yPos < (0 + BallSpeed)) {# t, z" P8 T+ K& d/ c$ m A. Q
yDir = "down";* B* T+ N/ O5 x" K! E6 @& d9 a
}1 J0 F& C7 Y% L5 [% d
}% k. j% X( O2 s+ Z
if (xDir == "right") {8 Y- d1 `9 S4 v/ ]9 Y& T8 ^
xPos = xPos + BallSpeed;" t5 c* G7 b0 X# f! h# R
}2 ]2 W. o# E3 \; r
else if (xDir == "left") {
1 l! a2 Y# K3 t xPos = xPos - BallSpeed;5 N" y: x: O& ?& l% `5 g
}
: s2 r9 T# g2 @+ ?: |$ { else {( K) P" }" ~) u$ Q2 J% C7 @
xPos = xPos;# `* k7 s1 M s
}' l# P" t. G2 j6 K/ w- q6 t1 X
if (yDir == "down") {* z2 C6 p2 R4 s7 F& h
yPos = yPos + BallSpeed;4 g8 ~( e5 K+ ?5 |
}
, m; z* a5 l: s4 f else if (yDir == "up") {
$ Y6 P' F+ S W1 y- J* I( e yPos = yPos - BallSpeed;- e. R n w2 I) g
}. }! d& J4 d3 p B H% {
else {
5 @9 o# K7 m: G, b- } yPos = yPos;* B% F8 ~5 F! [3 k
}2 R9 {; h5 y& w2 [3 I
}0 ]& C& @7 ?" u( `7 q# t. A5 F
. Z+ W( S3 v: P( d7 z& l
function hidetext(){. X( U/ a6 c& ^
if (document.all)
" a% X B+ L3 g2 ssupertext.style.visibility="hidden"* ^) o2 E0 @& q+ x4 c) L' k5 J2 T
else if (document.layers)* w( U6 T& k' k9 k0 [, L
document.supertext.visibility="hide"* R5 @$ Q) j$ L
clearTimeout(animatetext), q. }5 s5 p) q; \5 _ R- C
}
! [* o$ _* u) @! q3 L/ [+ m2 }8 \4 x$ v9 C- V6 M0 J
if (document.all||document.layers){
+ U+ L1 n, o( y. E2 O: K# }2 Bdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
) D) @: N1 K; G" q5 b! Kwindow.onload = initializeBall;- Y, c/ F/ i0 d8 k/ E1 y$ j
window.onresize = new Function("window.location.reload()");/ _6 q9 E2 \& u; Z
}. ` ?, x0 A8 @0 F2 ?. V: _& w
3 k: P& N" X- M9 t% A</script> |
|