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

|
网页之不断弹射的文字-特效
<style type="text/css">, D1 P/ x9 \" b# G. `* `
#supertext {
5 d+ u) m3 o" L2 @& o1 @/ `: g9 j3 Pposition:absolute;+ z$ c0 U$ T7 @2 J5 s4 X
left:0;
9 [) c# I, p4 {- C# R- ^top:0; N5 R% B1 t0 b* ]: g
visibility:hide;1 Q# p2 ^$ B* m; F4 D
visibility:hidden;3 D x8 s. d s2 X( a: Y1 C
}
! C5 k S" O) m, z. g9 `</style>
& B* A. a1 {1 ?3 E7 R6 S# u<script language="JavaScript1.2">
/ X2 ~' [% O$ o$ p<!-- 改变下的字体的大小。颜色-->7 O6 v `3 l. E$ h! @0 s
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'7 c: ]( D6 l) W
var hidetimer='';
: S, i8 X& y, Y<!-- 改变下的弹跳速度-->
4 A9 V; A- H+ c4 ]) @1 g8 @: L9 \var BallSpeed = 20;
- y7 X9 H+ K1 ^+ k0 zvar contentWidth;4 }9 E1 u2 p1 Y6 e
var contentHeight;# {5 n9 @/ D' K1 I# U- F! J
var maxBallSpeed = 50;0 n( j) C1 o3 N" L c' M3 R5 a
6 J) I- C& ? Q4 g% }8 d
. d" A }9 q2 y) ]( u# \4 pvar xMax;- h/ c3 I& t! ]# ]9 b9 \8 V" G: o# n
var yMax;
2 Q: u3 w4 _( p0 E2 H0 }var xPos = 0;
, }$ ^2 O1 C! s% m Jvar yPos = 0;
; ?$ V% r7 r4 U: h6 Ovar xDir = 'right';
3 h1 N2 e+ l3 t7 Y9 vvar yDir = 'down';% R9 x8 K" z, S: x
var superballRunning = true;
# N/ \. J' u$ J6 ]* g8 ivar tempBallSpeed;
, ]2 {/ v! S6 v( z# Q% c! @5 U2 v5 |var currentBallSrc;
% b! f+ a3 ^- G, ^var newXDir;
/ I' i7 H8 |2 Ovar newYDir;
4 d$ ?/ `8 b* H1 p( k) c4 X3 @$ [
* Q+ L. [+ F9 q+ N8 zfunction initializeBall() {$ l2 C# [$ t5 b
if (document.all) {
! ~% z. q F& `/ @3 }) p1 F xMax = document.body.clientWidth
$ r% B" ]& m) t yMax = document.body.clientHeight9 c" o/ O, A* p. s; [/ b* a1 i
document.all("supertext").style.visibility = "visible";
& E: @; h8 [! Z% @. D contentWidth=supertext.offsetWidth
9 ?$ P7 X" N+ z9 m5 ^) j; e. T contentHeight=supertext.offsetHeight
& ~* a' w" |+ J$ a }& } m' c' h; b6 L
else if (document.layers) {6 F A) Q! ]5 ] E( g1 x) q# c
xMax = window.innerWidth;
. U" k% Q. x2 b* Y% c# \4 L _; q yMax = window.innerHeight;
# b/ s) B' k- t* a contentWidth=document.supertext.document.width
- r& A4 h% Y' N% x$ K& m contentHeight=document.supertext.document.height3 L/ j q8 | n3 m" w
document.layers["supertext"].visibility = "show";5 [) b* r1 S7 |1 \5 e" _
}4 F& s( z; H" n$ ]4 T* _
setTimeout('moveBall()',400);" K) z% B$ F1 P" x5 o6 L
if (hidetimer!='')2 C( a, l, {) M1 w+ \
setTimeout("hidetext()",hidetimer)
! ]' H4 Z9 g% o }, X5 J4 @8 U) k% d9 l- d; t' [
1 g! F/ m0 t, H4 B3 dfunction moveBall() {
$ Z: J4 p6 d6 ^3 T if (superballRunning == true) {
( z! d+ T5 H, Y/ l calculatePosition();
2 ?5 m9 W% @6 m* V' ] if (document.all) {! l" m* t9 |* A" _+ d
document.all("supertext").style.left = xPos + document.body.scrollLeft;
; M+ s' j- x, g% Y) p& ^) @/ Z document.all("supertext").style.top = yPos + document.body.scrollTop;5 X) ?7 k. d" H2 X+ D
}7 c& A4 H2 ^" y* a7 A
else if (document.layers) {
2 e( a) u- V4 {) v document.layers["supertext"].left = xPos + pageXOffset;* v# q9 U6 g! \. w* u
document.layers["supertext"].top = yPos + pageYOffset;
6 y' l# Q2 s: x( w8 a# i }
* K V' Z5 L) N6 ^2 a2 I animatetext=setTimeout('moveBall()',20);
* j$ g9 w$ P1 `+ R. `( j. e }$ v0 i5 r0 [ R a5 T
}
3 e6 f" w4 J5 O' d: p7 g) f- ~: x; b* v
function calculatePosition() {4 {& _8 G$ r5 T, |/ x5 D- g1 k% C
if (xDir == "right") {
( @ [! S4 Y0 n1 {& M if (xPos > (xMax - contentWidth - BallSpeed)) {
& X2 U& }8 U: s% V4 u' X- q; Q xDir = "left";8 d- @" {% r0 H# [3 f
}6 u" a- Z/ k; q+ K# r0 I' [$ G
}2 y% h, K a7 x' W- {: H0 K! O+ i
else if (xDir == "left") {
% {5 G4 F: e6 \% m$ m, F if (xPos < (0 + BallSpeed)) {5 v: i7 {$ n h7 X/ I# X! l
xDir = "right";
' C) z6 ?2 D e2 w/ n }
/ A2 v% s7 D$ N' R- W. E }- u# H) h# e# C& X
if (yDir == "down") {6 k7 w5 Z! J; X% _
if (yPos > (yMax - contentHeight - BallSpeed)) {. }" o' I6 K5 Z7 ?0 s& C1 e) V B
yDir = "up";) w+ K+ |- w$ R7 R8 c: l
}5 ?9 n7 m$ {# Q$ y
}
' B/ z% x$ K8 E6 f else if (yDir == "up") {
: A# `3 o" b1 I" f8 f/ g if (yPos < (0 + BallSpeed)) {' {' M* K9 V8 J$ w A. ^
yDir = "down";# B8 P; c) {( x* q7 o& \
}
+ W9 O! M+ g$ U9 _3 D8 G }
% \# U: W1 x2 E9 o; s4 F5 k0 F5 Q9 [ if (xDir == "right") {* F6 @. I5 e4 }' P, Y
xPos = xPos + BallSpeed;
5 E1 O0 Q1 D+ z5 H3 j5 H }% w+ Z+ h w. g: I( \
else if (xDir == "left") {( N/ G- F& Q0 g7 o
xPos = xPos - BallSpeed;
5 ^& f/ R# E7 w$ ?2 q7 L& r }
4 ]- v/ \1 f7 \( ~. W else {. I: ~# ]" E: A8 U) j# ?4 x0 Q$ |
xPos = xPos;
; ^: q$ W v c2 C0 b }
. g, p# I2 G* @9 x if (yDir == "down") {
5 R# L# h7 _4 p. D: a( i" ~2 [5 H yPos = yPos + BallSpeed;
/ Y ^# `. ?& l1 _, ~# P }1 [) p. Z( o& c { E- W
else if (yDir == "up") {, J$ E6 {+ X& x
yPos = yPos - BallSpeed;
) w s P! B7 h }
% ^6 f* e8 m x3 f9 M0 _ else {
& C( x/ P! b: ]2 `# a- I yPos = yPos;
- s/ a2 w& I2 p% R2 l% H }
7 @( h/ H2 L2 W i& O/ I }
" ?1 p' m6 ?; E& O7 A1 e8 G: e. o) z4 W$ w, c; e: A5 o
function hidetext(){
" V9 I: O. L5 Gif (document.all)/ {1 x) `" r8 j" S1 e
supertext.style.visibility="hidden"! q+ S! s' F- M& H/ ^& ]$ A% v
else if (document.layers): T- k" n1 ]1 ~, C4 _7 b
document.supertext.visibility="hide"# G7 B. V9 [4 x. E& T
clearTimeout(animatetext)% v& P( L. D: X; }% ~9 S7 H3 Y7 C
}
. C& {. m5 y0 T! r5 h
* M, J: {+ P/ m& }& U1 Fif (document.all||document.layers){
7 j' u9 f- Y( Vdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
* {/ h$ @+ Y8 Y( ^window.onload = initializeBall;) X- S1 Z# |$ E b% G
window.onresize = new Function("window.location.reload()");
l7 v8 @! Z3 J' K}
+ ]0 P+ U" _% o' O, H" ?+ Z) G D: w. h0 H" j, d
</script> |
|