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

|
网页之不断弹射的文字-特效
<style type="text/css"> s6 W* B) b& V; a x0 c
#supertext {7 Q# F7 w" Y# I
position:absolute;
; q3 m2 C7 x& q& Nleft:0;% n3 c2 W8 G. Y5 V' V, {$ ~7 s
top:0;
7 n1 G, |3 _7 a+ Y zvisibility:hide;
% w2 ^# ~+ T4 E+ | n" N+ Dvisibility:hidden;
9 W3 T. _. I6 i% E/ @- `; h}
: i! } ^/ \$ T* x8 O0 @</style>
; H6 B, A9 t7 f, Z6 y! ^<script language="JavaScript1.2">
; i# |/ K, j6 W: b# H) j( K<!-- 改变下的字体的大小。颜色-->
5 E# S; M; c: ?) \4 b- Evar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'" e& j, b U& N+ J& ?3 Z; w
var hidetimer='';' _# @ }0 v* L9 G) }: f8 y
<!-- 改变下的弹跳速度--> R4 i9 |4 u4 c3 c
var BallSpeed = 20;
0 |+ }- V* ]& h) z8 Pvar contentWidth;
5 ]6 Y) j2 O- a6 C) uvar contentHeight;. G+ A5 e2 v2 _) ?# z
var maxBallSpeed = 50;
; ^' V! |2 L/ ?6 m0 B! \- s0 v. V. t" H* H" J2 k1 u
5 w0 j/ x& F! Avar xMax;9 P! v, M- a! H9 ^4 A* a3 o
var yMax;
* v) F: _ E$ a% Xvar xPos = 0;4 v. r+ N H% y5 H: M# T% Z
var yPos = 0;) i7 L* K* A- o$ C1 E" G$ [
var xDir = 'right';
; z6 t9 w( i8 _2 m/ L6 Mvar yDir = 'down';
" k- N: p" B7 A8 A+ Zvar superballRunning = true;
r% T* q( q( c8 i8 gvar tempBallSpeed;( i, Z6 t8 u, I5 ^: ^
var currentBallSrc;- W2 c' T% `7 a3 K ?4 Y* }
var newXDir;
2 ~8 K- y) ?* n% E$ ?5 Kvar newYDir;
" u' o x) Q; M+ I2 O5 O1 I4 L3 T1 i; ~4 [% ]/ f9 M
function initializeBall() {4 S$ W* ~' l1 }
if (document.all) {( j* [8 r7 m( x( L4 P
xMax = document.body.clientWidth+ V) x" i2 b1 n3 K
yMax = document.body.clientHeight6 B# F+ [3 T- V- P: _
document.all("supertext").style.visibility = "visible";/ P. g) S( h1 |) v' K `9 q4 \
contentWidth=supertext.offsetWidth2 J6 Z2 K. c# a& g: u
contentHeight=supertext.offsetHeight
: g0 F3 _# O9 c }$ ?$ d. R* o# d0 U# K
else if (document.layers) {# v; ~9 ^$ a( w4 f
xMax = window.innerWidth;
+ T& H: j3 v: K( g8 z6 l yMax = window.innerHeight;
. a: C4 L* v# |5 O5 a) Q contentWidth=document.supertext.document.width
# M& {) a7 o6 [; G, f, h5 F contentHeight=document.supertext.document.height* T$ d* Z+ V6 j/ u8 o* g: f. J
document.layers["supertext"].visibility = "show";
% M% A( u+ ]' o4 x6 q) s }
2 x+ ?2 y5 x9 ?, G& i$ M' u setTimeout('moveBall()',400);
* G, Z4 H1 N* V if (hidetimer!='')9 [& U+ j4 A q7 F* K8 o1 x" H
setTimeout("hidetext()",hidetimer)) s. Z; n; A; m, [
}6 D) [8 i; D; M% @: ?
6 ]& n/ e$ ]2 i$ n: c4 ?
function moveBall() {
) p9 d: W5 ?1 {, a if (superballRunning == true) {" G5 }& s. H6 a9 P! v# c
calculatePosition();
( ]- b% D y) F' n5 r8 g x* i- L if (document.all) {6 @& m# h3 G1 k2 |, C. V; X: f1 z
document.all("supertext").style.left = xPos + document.body.scrollLeft;
# m" r7 j) J! p& ^ document.all("supertext").style.top = yPos + document.body.scrollTop;
8 u! R" m, s( F& i8 w& J7 w6 p }
# L$ N) \5 s: Z1 ~- M else if (document.layers) {
1 I7 l$ |" }8 P document.layers["supertext"].left = xPos + pageXOffset;
" U) f5 P! ?: O" P document.layers["supertext"].top = yPos + pageYOffset;, t! g6 x1 |% q( k: L9 h$ S
}
6 x% v0 C; [" U, {3 w animatetext=setTimeout('moveBall()',20);1 B8 d: g5 N( {, d' Y
}
# ~6 I/ E' f9 e3 c/ o }2 j( U. n- t9 `. q9 h7 w+ A$ Z* t6 f
( ^% E5 l5 N# H
function calculatePosition() {$ ?0 N# }7 I, _# e d. m( [ w
if (xDir == "right") {" B" l) n- p1 F; K( ^2 J( Q
if (xPos > (xMax - contentWidth - BallSpeed)) {4 {* u* Q) ]5 ?1 |
xDir = "left";! Y5 i4 E* Y [) F
}$ ^& O9 a2 c: J- S
}7 Z' L9 _+ q7 w# Z4 N5 I5 D$ J! i
else if (xDir == "left") {
4 f ~0 l- u+ z" u; y: I6 o% y/ o if (xPos < (0 + BallSpeed)) {& ^4 [; X% c9 T6 ^ g
xDir = "right";
0 }4 G1 Q, N! {! S4 `1 c }, g! d1 W( W6 ~- m: f) a X$ w- {
}
( c: f) T& K$ ?# T+ A* Y if (yDir == "down") {
3 e) F: T# G S' P2 c/ _ if (yPos > (yMax - contentHeight - BallSpeed)) {5 X, }4 d8 l) x/ l$ D
yDir = "up";% ]7 `8 C& A% q/ o
}7 d& D* s1 p4 ]9 M9 T' j
}
1 _4 e2 W0 e6 v3 q; i3 F+ Z# S/ ] else if (yDir == "up") {
y+ `9 m( k" _9 K5 x8 {2 n# F0 l if (yPos < (0 + BallSpeed)) {/ }2 G* \5 u3 h2 M0 L% C: u( q
yDir = "down";; [1 o: d* u; G
}8 G9 j+ d: z- d5 h9 a
}8 m. S* ^5 P2 U4 L$ z8 s. W v
if (xDir == "right") {
|2 s! Y* M5 E _' U* q xPos = xPos + BallSpeed; X/ v b# A& v
}
U6 Z2 y) u6 N, G else if (xDir == "left") {
8 a! ?# j. g" k# [# { c xPos = xPos - BallSpeed;
; I9 L+ t; h" P# C% Z4 B }
1 F6 Y [. q4 Z, w else {
7 y' `. L/ p7 E" G5 l5 ?9 F8 | xPos = xPos; B' @5 u+ X3 s1 b
}
3 s1 R( W, D5 R2 q if (yDir == "down") {
- `7 m2 f: z8 j/ Z! E, L yPos = yPos + BallSpeed;- |$ ~" h. s4 F8 j; s& q
}; {) i! K- R; D+ I; z3 c X
else if (yDir == "up") {2 o- w0 E4 d8 v& b" I
yPos = yPos - BallSpeed;. s- M% ? ?, G7 b9 f+ F% p
}4 G2 t: ]# R* L& L7 V) a+ K% W* E
else {
; A3 j* m( H* E& O9 K3 M" I yPos = yPos;5 Z1 R. z t+ |- N' b' V
}% P0 }7 e5 j6 H- R. {: \
}
4 x9 c; W7 p* g$ V0 f+ F5 H0 S1 t1 {* X
function hidetext(){
; k$ |; b- }8 y9 d6 `9 Y5 Qif (document.all)
; Q! @* z7 S0 U6 v6 Tsupertext.style.visibility="hidden"
0 r5 C# T0 z y' Telse if (document.layers)
: X# P2 P# S; V. _8 adocument.supertext.visibility="hide"
, n- D& @ n+ n9 K: ?clearTimeout(animatetext); R3 M0 f( M- J
}
+ T; q. g8 i& }' O! |: B7 ?$ t- C7 N# X9 T4 Y$ c2 h' T! J
if (document.all||document.layers){# D) ?& T7 [$ D# j
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
) h/ v9 s( A% u G' swindow.onload = initializeBall;
$ l* K Y7 R# i( n rwindow.onresize = new Function("window.location.reload()");
) e5 K1 ` K- n }; T% W6 o5 W c}
3 p- S2 [/ P; w. a
' p3 ^/ r1 P3 g0 @- u% H</script> |
|