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

|
网页之不断弹射的文字-特效
<style type="text/css">0 g) K- l0 Y# O8 n7 e
#supertext {
2 V2 |3 [( ]3 h! U3 Vposition:absolute;+ k. b6 n- a, A+ T2 T6 `3 o
left:0;. v7 r, W' K0 j1 ]" K% j
top:0;& g. `" E) m+ G* c
visibility:hide;+ L( T- {* Q6 g$ J& p) U( i
visibility:hidden;5 _" ?0 W6 x0 V" r7 L
}
/ t+ X# O5 r E* p( P, }</style>$ V- s6 f6 W1 g6 U. n
<script language="JavaScript1.2">' n& }4 s1 F C2 x
<!-- 改变下的字体的大小。颜色-->
' G* M* p3 ?. [2 }) z4 n. ?var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% ]% h- `# j+ e. h' Hvar hidetimer='';' U q$ U( R6 R8 k& y4 |
<!-- 改变下的弹跳速度-->
. @6 _* r l4 q: S# x( @var BallSpeed = 20;
1 q1 M7 p5 U5 c5 \9 z7 U/ Zvar contentWidth;
- {' J$ t" s* O8 N& evar contentHeight;
9 M" S; @; O+ bvar maxBallSpeed = 50;8 b5 q' ]( |% g0 Q) N8 q
6 U& e5 V- ]4 _" {& o4 @
^( w5 g0 W/ W o: v: \7 jvar xMax;/ \8 X6 y. n: t' @9 n8 m
var yMax;
. g1 p. w9 T: {/ K# B* @var xPos = 0;
8 X6 n6 G7 p/ Ivar yPos = 0;. j/ i" t1 |; K8 M& W" i
var xDir = 'right';! I4 u- \; ^ J, [" h. O
var yDir = 'down';
& l3 z6 N6 B" j9 [var superballRunning = true;
% Q+ c) ^, Z- y7 r; A p4 ivar tempBallSpeed;
" [- Z9 S* p5 X% Z9 b/ Zvar currentBallSrc;" y! c' c# z7 w5 y+ O# @& d
var newXDir;; A; t2 J; v' c# Q$ O' b: \1 U" o
var newYDir;
/ k1 E, n- k; m6 g8 n
& ?- @+ X: q8 a' G2 Rfunction initializeBall() {
- N: i5 r; n5 e5 Q1 I if (document.all) {
" M1 z4 w& u; D" t, r9 A5 q6 x xMax = document.body.clientWidth
9 J# d% r+ j. D; U, M* e yMax = document.body.clientHeight9 _3 @- u$ f" [0 G' b* e9 V. e# l. [
document.all("supertext").style.visibility = "visible";
* \ J6 x* N, }& v$ r, G3 V$ K% m contentWidth=supertext.offsetWidth- ?7 G% E- H( [4 v
contentHeight=supertext.offsetHeight
% q7 a0 V+ B# N7 h. j7 u6 A! R9 G: x }
. S2 P. w6 Z" C" C' P6 d else if (document.layers) {$ W$ O7 L2 g( @* j: x# {# b; G
xMax = window.innerWidth;
/ b7 ?; ^8 |/ Q% @1 N! n, j* Y. ]$ I yMax = window.innerHeight;+ c- ^% M O j b5 d$ G, l6 Q
contentWidth=document.supertext.document.width4 ~: J5 e% F0 ~
contentHeight=document.supertext.document.height
% E9 T2 c( r- ?# I document.layers["supertext"].visibility = "show";
+ p3 D& |4 y; I1 _% i9 q+ X S2 N4 g! Q }/ @9 z/ d( t: O, p! r% i& [
setTimeout('moveBall()',400);# G0 s: _ @! f) h* _- Q9 O2 f
if (hidetimer!='')3 M6 U5 @% b: `* X# Q+ \! }
setTimeout("hidetext()",hidetimer)
; N! a& |* t6 I8 Y! h8 l }
& t8 m* k$ V) B9 o# a
" ~' }. D/ ^' @; a- R5 a! Jfunction moveBall() {
# y" U* L/ C6 L5 m' M+ J, i if (superballRunning == true) {, C/ X5 R: l( z3 n9 `" d
calculatePosition();4 O( r1 s& ^2 D+ ^# ]6 G
if (document.all) {
/ i1 P6 T3 K, k/ ~( ?) q document.all("supertext").style.left = xPos + document.body.scrollLeft;& F: @# G0 ]! r2 p t; o* j
document.all("supertext").style.top = yPos + document.body.scrollTop;
; V/ \6 P' {1 x! L }
! p+ x/ {( w$ `/ z# t) a& T else if (document.layers) {, a& I* k. d4 v/ ?& g
document.layers["supertext"].left = xPos + pageXOffset;( g4 _3 Z1 M1 B
document.layers["supertext"].top = yPos + pageYOffset;( o4 w A* S J2 K
}2 L. A2 q( y8 f6 a. K
animatetext=setTimeout('moveBall()',20);7 e$ u" |) }0 C8 O* v' X" \* X
}- ?; {5 A/ T: s+ K b
}
$ T! {/ d) f" k! f3 K+ i R% d8 Y1 @$ D2 k/ O
function calculatePosition() {; i0 z) J3 Q6 m0 n, F" G0 Q
if (xDir == "right") {
/ U3 e8 D7 y! n; T5 t e4 ^ if (xPos > (xMax - contentWidth - BallSpeed)) {
; c: D6 w' t3 u* V! N xDir = "left";5 Y2 o) i- A: S% e: Z$ E
}
0 P6 _: m6 L& ^) g: ] }7 |) y5 s" V' u) k' @' |
else if (xDir == "left") {
9 v' N: i" R% [) V8 I9 [, a+ j if (xPos < (0 + BallSpeed)) {- v1 D- C! _2 x1 ?1 n8 v
xDir = "right";
7 q* o" K, R( Q' D7 d# o5 D }
0 M9 V! @6 u, Z1 Q& `" ~ }3 S; J) i( p) S
if (yDir == "down") {: J3 d( P8 U; I z, h9 K
if (yPos > (yMax - contentHeight - BallSpeed)) {
0 W# P4 g2 }) | T6 E2 z$ V: o0 H yDir = "up";2 U8 Q5 L; j. L' F9 y
}3 S5 |3 C: y! V) }+ V
}
! [, j" [; d, R. J1 z, T" ^9 s2 n else if (yDir == "up") {
# S# E' [ \6 R+ }3 J0 g2 E if (yPos < (0 + BallSpeed)) {7 M! p, E# H4 X
yDir = "down";$ A( g" v; Y8 u, @$ D
}* z3 s# X- D! b1 b; R$ m8 F
}
7 a; @2 J" Y/ n; `6 @9 j. l4 Y& v if (xDir == "right") {* u3 h6 o4 Q5 j/ l- T1 y0 h3 s
xPos = xPos + BallSpeed;
8 Y8 V' Q* M* _' j4 W }
& a5 u6 v. F) Z0 C" T else if (xDir == "left") {! i! C' B( \8 [+ T
xPos = xPos - BallSpeed;
$ Q& c, E7 b/ w5 ~# w }: _" ~# L8 l% h" L' S
else {- q- d8 W8 j, r) L
xPos = xPos;
" I, R- z+ l3 F. @% M+ w }
5 t. ~' q6 a7 K( c) q( p( ] if (yDir == "down") {& i# D9 n- w4 W$ v5 a! z
yPos = yPos + BallSpeed;
8 u- W2 j% \3 ]; K/ @. ]2 c, j }+ ]( N& v4 u s4 z' ?" ~) L
else if (yDir == "up") {
& Z7 o: q8 k7 ]6 P+ h yPos = yPos - BallSpeed;1 Y: S6 x/ Z" F/ H
}# z/ e) P) ^# G( J: h% K
else {. w9 m6 | q) D z! G8 x
yPos = yPos;
9 ~2 d! c! i) R0 ] u0 B }
2 G3 l1 {4 `; k7 E }" ]4 ?+ Q8 {( [) l
; w4 v R" E Q) x9 O2 M7 V. _
function hidetext(){6 \: ?! t0 F2 m. g ]
if (document.all)7 z% k/ x$ v6 m7 D- J7 u7 H
supertext.style.visibility="hidden"% @$ J4 Y' z3 o9 ~! `2 |: P+ n* L
else if (document.layers)
/ a' y7 R' W& n/ O" I$ e2 n. Fdocument.supertext.visibility="hide"+ c3 _2 \/ O1 x u$ {! V; s
clearTimeout(animatetext)& u" U2 V& r \* y: V3 a
}
& e' _9 z. T; c% {: F5 H% l6 @ J j4 ]; L( e4 h
if (document.all||document.layers){- v T8 \1 _# s+ X' ?
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
7 a% B! ^, Z; h; e6 s$ n5 _# jwindow.onload = initializeBall;
$ Y" g1 l/ J0 Q; D* U& T; a+ e7 ]) k+ ewindow.onresize = new Function("window.location.reload()");
! _4 l5 V/ L7 q$ p6 {}
- O- f7 |0 ]! J8 x, i
D' ~8 U" M2 J7 X/ ]0 z+ E</script> |
|