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

|
网页之不断弹射的文字-特效
<style type="text/css">; l M& j3 J9 W! V. Q
#supertext {. I }% f2 z# }& v
position:absolute;
2 c, [( U0 K3 m: N' K; c9 G* q$ ]. ~left:0;) B7 h; p' a: c; |7 t; H6 O
top:0;
. n$ Y5 k2 G3 ivisibility:hide;% _4 y6 l5 H9 w% N+ N3 O9 `) z
visibility:hidden;
; q' x# |! t, ?) j}
4 S8 c8 k( t% D% @) U( S+ R</style>$ A) \% a$ A+ T/ H1 `: J
<script language="JavaScript1.2">
+ H( m) w$ U, Z) F# }* g, w, V<!-- 改变下的字体的大小。颜色-->
9 S3 C7 A- d9 _var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'. i+ |% m' I5 y2 Q$ e! K/ Q M
var hidetimer='';* A; i) n9 e ]- q, D# v
<!-- 改变下的弹跳速度-->' H p2 @3 N5 ~. c+ V, t0 W: E$ s
var BallSpeed = 20;! i+ Z- u$ J; [) o2 k5 u* }
var contentWidth;% E" q5 e& ` h
var contentHeight;, f) s9 N2 G+ m8 y. @
var maxBallSpeed = 50;- ^* R# W% D. I1 E$ O+ @- [
Z6 H. m9 b1 [6 f) s0 {
# _7 ~. z$ m4 V6 j+ H( wvar xMax;. p; x. @' Q+ z4 @
var yMax;
, z' d9 g: E# w* zvar xPos = 0;
! U0 c- P6 U: t7 ovar yPos = 0;
' c$ v# t. B/ t3 [4 H7 R9 tvar xDir = 'right';
9 }- g" p, r2 |5 w) E' \( E! h9 dvar yDir = 'down';
2 H2 f1 I( `3 @% _3 _) W wvar superballRunning = true;7 O" M1 r) v8 i: K9 o* s
var tempBallSpeed;4 U* g! u& X- A T3 C$ |( T* [* w/ l
var currentBallSrc;# M: a4 ^; b2 h: |! F
var newXDir;. d& \9 S6 D6 }1 F
var newYDir;
2 [ P/ ]+ t9 D5 Q! \& q& N) n% h }( v6 h- S
function initializeBall() {
2 w# O" q( @! m7 N& [ if (document.all) {% z) ^+ F' I5 d: l% B
xMax = document.body.clientWidth# ]% a8 b9 V6 }% s, B
yMax = document.body.clientHeight
8 P8 e/ K+ T7 x, D7 |) ? document.all("supertext").style.visibility = "visible";0 h- @$ O4 h- H' ~& ~
contentWidth=supertext.offsetWidth
L7 N4 g/ K; n/ J) g% Q" ^) f contentHeight=supertext.offsetHeight7 I5 C; R0 M* w+ F/ ?5 v
}- t/ |6 w; G- h# H3 M, a4 ?
else if (document.layers) {# M- C: i y" B- F9 b# S
xMax = window.innerWidth;
. x2 {- [0 f: N' u# P& p yMax = window.innerHeight;- F: ]2 f- E( @1 x
contentWidth=document.supertext.document.width
8 c4 x: M" Q( E* a( e contentHeight=document.supertext.document.height
* b* o1 c: Y) O; _$ D3 f$ W" w) ` document.layers["supertext"].visibility = "show";" e/ x3 h- x8 S
}. P+ u; _$ ?* j9 P- S
setTimeout('moveBall()',400);
0 V* G# M6 [2 ^2 t( k) a if (hidetimer!='')
* c2 p0 G/ E: Q" }1 W' w setTimeout("hidetext()",hidetimer)
' }' X) j9 ?' R7 f% }2 ^ }
6 ^& y0 j' Y7 {* _! z, a/ L; J6 w
function moveBall() {2 h, n1 B3 z# w9 K% C- g
if (superballRunning == true) {
& T( d' V2 d( v; }# K6 B calculatePosition();
1 K G1 e& J- l1 |. s if (document.all) {3 d I3 I( [7 E( x1 z
document.all("supertext").style.left = xPos + document.body.scrollLeft;
; V% s) ?( ^8 m2 n: g7 L document.all("supertext").style.top = yPos + document.body.scrollTop;7 a7 E3 q4 ^3 q0 q" S- H7 b
}
4 Q2 f9 `! c- m* l0 R. O$ q H( t% ` else if (document.layers) {
+ X+ K5 J0 g! D/ S9 y document.layers["supertext"].left = xPos + pageXOffset;" \: x* u$ C) V
document.layers["supertext"].top = yPos + pageYOffset;
9 L& h( O+ G# c4 B }
2 C2 f# C1 w/ c animatetext=setTimeout('moveBall()',20);; p- U" i* E4 f Z# h
}
, p, P/ @. U- r) B }6 u- y% A) h7 W s; J
; k% C+ k$ s$ y3 @/ Nfunction calculatePosition() {
, V3 R$ [5 Y8 ]- C if (xDir == "right") {
6 v0 o0 W7 N N if (xPos > (xMax - contentWidth - BallSpeed)) {. K. g" R6 u/ b' N! p. y4 U
xDir = "left";: }6 I) ~/ ~/ f5 @' p+ ^9 j
}0 s0 l4 x2 [9 d# c1 R% I
}+ \; x+ i; h: F4 X/ D* x9 S$ d) U
else if (xDir == "left") { }5 n, P) P+ y% j: r6 K
if (xPos < (0 + BallSpeed)) {
( k& t. [% F0 P xDir = "right";1 R/ }+ o0 h! A0 h9 S$ O& c
}
8 f) ^' z/ [6 ?" S) c }4 I" ~ A3 T. t2 s
if (yDir == "down") {. x# h6 q! A! x9 _
if (yPos > (yMax - contentHeight - BallSpeed)) {
+ {( ?+ D n# {( j2 E* p& A yDir = "up";! T# ~! w2 t2 O; z; t4 u
}$ C% G, |; e f
}
/ j8 k, y3 _ m- ~7 w- X7 M else if (yDir == "up") {2 U2 G; B; u5 i8 g
if (yPos < (0 + BallSpeed)) {, ~3 U9 \% H1 F( f4 S8 G7 M
yDir = "down";# h# w w9 D9 j! ~0 a9 M1 ?' @
}
, p+ z% i: h# F' s- ` }
; P2 x0 K. ~2 k1 E if (xDir == "right") {
& [/ d( U2 @% R# Y' ]* O* b xPos = xPos + BallSpeed;
/ \( m% o) j3 L0 p }
) s' t x- E8 T( W2 _7 B else if (xDir == "left") {. z6 [( }4 H) H; @3 Y" {
xPos = xPos - BallSpeed;
8 i2 T; U& t$ v2 b+ ^8 s }
& b5 s2 ]( y3 v0 c# _ else {
7 f9 u1 O. l2 K& V3 { xPos = xPos;$ `0 A8 j7 N m8 f' r
}
2 v3 t% h, [ J3 S/ S if (yDir == "down") {
/ R& ~9 a1 Q) t! q& E yPos = yPos + BallSpeed;
# F- ^$ i: U7 k3 p, x: q }5 I. z7 K, K$ z. Y& q
else if (yDir == "up") {( g2 f' e3 g2 c2 R, J5 g+ I
yPos = yPos - BallSpeed;
0 R- e0 l Y" F7 S9 J) [ }
5 {4 W" g0 r4 S' \5 J& f. g else {
# e% W7 q8 f, B: }' a2 r" E) n2 K$ R8 v yPos = yPos;* L& ?2 x% t* G" K' T& A) u7 M6 h" [* M3 |
}
9 s# Z' x8 ^/ t/ i( c7 p }
! {8 A5 t9 s# L, V( i) _. t3 _7 G |" Z. ]. \9 Q8 m- x
function hidetext(){
; `' u7 @! d# \# m5 x# uif (document.all)
( |1 ~! |. R% Esupertext.style.visibility="hidden"
* F% ]4 d. F9 Z$ ]else if (document.layers). b6 Q4 C9 Z# C2 w
document.supertext.visibility="hide"8 r3 H4 |! X! @8 q3 p P+ G
clearTimeout(animatetext)" _7 J: V h3 T# m3 o) `3 v
}
( H7 Z+ v x; k# Z9 b- | t1 @& m
: Y) }1 h$ a0 s) Cif (document.all||document.layers){
9 L c* v0 P: c# W) b1 t/ u. }0 ?document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
2 T1 C* E* N0 u: fwindow.onload = initializeBall;2 }0 i9 Q0 U$ [
window.onresize = new Function("window.location.reload()");
/ l: y2 d+ m4 \; K p} m& x% x* V, ?- z& O: k$ O+ ^
4 l$ u8 m0 [3 G# ^</script> |
|