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

|
网页之不断弹射的文字-特效
<style type="text/css">7 _; D* W& J' e& L* T6 B; D
#supertext {
. i( N$ b5 C4 C3 O- Jposition:absolute;
9 w7 ^- d2 G1 Q/ O6 m) Rleft:0;
! f; I' V7 Z$ Ztop:0;# M' B% [" \$ {, E# U
visibility:hide;
* t7 `' p3 ]# `) ~" f5 A1 ?, bvisibility:hidden;
% o. _) ] L& [0 O9 p& Z2 p3 t}# `/ L/ u# y* Y5 l+ h
</style>/ \9 @- U3 j0 i3 @
<script language="JavaScript1.2">/ Z0 N! T: A, r7 }$ |
<!-- 改变下的字体的大小。颜色-->: ?" e+ `- b9 j1 ^& c% Y
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
9 m R/ }$ F$ `5 }9 U9 l3 B% M2 zvar hidetimer='';
& }3 O- a# i! E" L d<!-- 改变下的弹跳速度-->( Y! s) G7 K6 u! V' H7 r1 q
var BallSpeed = 20;, u" |' J) @' @+ X6 j4 T: o
var contentWidth;; r3 @ e B5 E: J/ j
var contentHeight; r7 f) q1 c1 O8 q; V" p, e
var maxBallSpeed = 50;
# t3 {+ k6 k9 t
1 m1 Z2 U# H4 u/ _8 O: I# a, [" Z' V4 F
var xMax;) Z/ m% t& f' k7 G
var yMax;8 o& u. c; I, {! N
var xPos = 0;) D) q* U9 D- V9 x ?
var yPos = 0;; P0 ]* X4 @( q/ }2 j7 C \
var xDir = 'right';
8 w# f& y1 C; M1 @- E/ {var yDir = 'down';1 v6 h, @8 h/ Q, n" `9 X6 K
var superballRunning = true;$ B, [0 S: U; G9 V2 @
var tempBallSpeed;1 f: _9 N e; E! f
var currentBallSrc;1 c! L" r0 u8 w) q9 u& ?# s9 M7 S' k
var newXDir;
% u6 M( w- u9 e2 Rvar newYDir;: d: a# {, |5 t; Y5 i$ d/ ?
) d, F! b7 e3 r0 Q+ ]3 x7 Yfunction initializeBall() {
5 G* {) }7 e' t! C4 W; w) J" K! c. P1 p if (document.all) {
+ e) a& Q G9 v5 B8 T& c) w xMax = document.body.clientWidth
4 L4 m' ~3 u) [% C yMax = document.body.clientHeight' s" c+ ~2 v& S$ U0 }, j: H
document.all("supertext").style.visibility = "visible";: u5 h/ c5 B( ]. P; N
contentWidth=supertext.offsetWidth
+ @1 J. k' ?0 E) w' Z: H contentHeight=supertext.offsetHeight% b! u& o" f* |, { o- d
}/ L1 K* }7 ^% Y2 P: Z7 G/ q
else if (document.layers) {
4 q4 Z- U! a) T. l M+ m' H/ a xMax = window.innerWidth;
( u( V6 P- x; s3 I+ | yMax = window.innerHeight;
) O+ p9 q# f* R$ ] contentWidth=document.supertext.document.width
' }2 Y' V; }0 C" h H9 w6 ~6 A contentHeight=document.supertext.document.height
7 v& ?( P' ]- B. y document.layers["supertext"].visibility = "show"; G2 p4 Z% ~1 z/ x- B
}7 q' Z3 _; Y5 E1 a, @9 H
setTimeout('moveBall()',400);
# {) L" U6 [' y0 V! ?9 E if (hidetimer!=''): A# G, H+ |& H3 K: N6 {
setTimeout("hidetext()",hidetimer)( d9 x. x% R w- e
}% g) s% u4 ~& n4 L7 k: }
( _3 s! m m# q3 E7 Z! ^
function moveBall() {
5 Q$ h5 r/ j: i if (superballRunning == true) {2 _8 T; I2 q$ E) g" M6 u4 |3 b$ ^, D
calculatePosition();0 T1 Z4 j" X0 ]& p) D
if (document.all) {
5 k5 ~; F% w+ W2 G9 m7 g, G document.all("supertext").style.left = xPos + document.body.scrollLeft;+ O1 x6 s8 r8 a
document.all("supertext").style.top = yPos + document.body.scrollTop;
: W6 ~5 D, j" k; f }/ n9 e0 C4 B ~& E P5 I
else if (document.layers) {
' O+ k- g/ g9 M: f! r document.layers["supertext"].left = xPos + pageXOffset;
d: ?1 q, _9 M) z/ G( F7 y document.layers["supertext"].top = yPos + pageYOffset;
- A1 c$ i ^# A: K1 s }1 i/ k8 m- Z _. e
animatetext=setTimeout('moveBall()',20);
7 ^& i( e/ @) p/ n }9 G$ M. |/ q# p9 r
}0 k9 K& Z, y, f; N0 K K. }
: D. M9 u0 d4 s
function calculatePosition() {; x T) j. b8 A3 Y) |1 q" h
if (xDir == "right") {( C/ A$ g1 a0 `* Y
if (xPos > (xMax - contentWidth - BallSpeed)) {
2 S9 l m8 t: I% D5 k- @/ n xDir = "left";& _- g6 ^9 {4 O7 f9 H) g
}2 X+ ?3 x8 X/ c, q+ V z% h
}
/ w8 ?( o2 ]( l# Y! A else if (xDir == "left") {4 j B/ k# \7 C4 m% k
if (xPos < (0 + BallSpeed)) {
8 S" O$ P3 `- k xDir = "right";$ T4 j% m* x V9 A; D+ n
}# |- k- _/ h/ |) A: t2 M
} o6 Z5 {7 o3 d7 Q/ m0 T! w
if (yDir == "down") {
# y7 {4 R6 k9 D( h1 S if (yPos > (yMax - contentHeight - BallSpeed)) {
, V& ?$ H, j8 a2 x/ @ yDir = "up";
& L* d7 Z/ r, J# S* B }
5 K" M" L/ H: @5 o3 y7 d8 b }
& I/ Q( q5 n9 m else if (yDir == "up") {2 l8 n+ W- l' \0 _0 }( S" I: i
if (yPos < (0 + BallSpeed)) {2 ?1 f) j4 G; F$ P5 U' G8 R
yDir = "down";' O: a% G7 A( M7 d. S; h
}
* w, e6 R: u, _ }
% W4 w+ n+ c1 \9 j0 n) H$ { if (xDir == "right") {) p0 C* J; U& y8 g3 P: x* L- o
xPos = xPos + BallSpeed;- H! b- E/ m, [. B/ p/ o
}# w9 Z9 v! o3 C1 p3 ~
else if (xDir == "left") {
- g5 K7 Y! \4 o/ v" f% P xPos = xPos - BallSpeed;6 w* E! t; _# p4 \' s
}2 W f5 F6 u0 u# H! ~
else {
# G/ C- ~/ Q2 }2 s' f) i# n. r xPos = xPos;
- y) ?, b4 h2 K& Q! o" p }
! F. b4 P9 ]) ~ if (yDir == "down") {* |3 c0 [3 Y0 l* V* I+ }* M2 B
yPos = yPos + BallSpeed;
! P6 ]6 B0 p: ?/ {0 t/ _1 g }
$ [7 X8 ^4 P' D8 i& L3 D else if (yDir == "up") {' Q q+ z5 _4 h# Z
yPos = yPos - BallSpeed;% m0 p! l& x" @ c- |3 f( m: t
}
) I' E' v4 j$ }- X else {
7 f1 Q6 D8 }5 D$ e k, E yPos = yPos;
$ x, q1 z% v: Z/ K% y; b; i }
$ @$ z; S* O2 X# ? }8 u2 \" x% x- i7 Z+ S* s
: k5 @# P/ W Z) K" K, P
function hidetext(){2 c( ?: o- X" L3 Y8 F S
if (document.all)7 S4 E4 V: _! W3 X0 Z% U; V+ C
supertext.style.visibility="hidden"# C1 N% u) w& i' w, z1 g- Y# |( W. L
else if (document.layers)) ^) x+ k) X3 k# _
document.supertext.visibility="hide"0 p. g7 j, t: i
clearTimeout(animatetext)9 ^4 Y/ n k! a7 L
}4 M4 U1 \7 x( n$ o* J z+ C
7 \& } c% |' J; x
if (document.all||document.layers){
' L6 i5 [1 @ {$ G J& Wdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
$ i* Y8 v# D$ t, |! M8 wwindow.onload = initializeBall;
# }+ K! e( e- t& xwindow.onresize = new Function("window.location.reload()");
' _5 n1 [: G$ ]" h; h}1 s6 w; s! G" A! D+ p$ N1 m
1 j8 J# m# m( K& b D
</script> |
|