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

|
网页之不断弹射的文字-特效
<style type="text/css">5 U! e: }# [: I
#supertext {
7 M2 P" ^1 D( b' qposition:absolute;$ Y5 x; E) S! y/ z) q% W4 w' N, w
left:0;
6 o, L7 d' o: F- Jtop:0;8 t) o! W- f9 K4 c
visibility:hide;9 p4 V& T7 m4 s( `$ b- ?
visibility:hidden;% h& f) a$ d& Z
}6 L1 e3 I7 K$ B! B7 L- a% p! Q
</style>
7 i; O' R5 |' d" B8 B- l1 S<script language="JavaScript1.2">
$ }, w/ ]3 |# J) m' A<!-- 改变下的字体的大小。颜色-->" N4 l0 X/ F: R: ?* v ]
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# n! u+ E$ E4 w4 y. f' n9 \3 v" W
var hidetimer='';
U# ^0 U9 A9 d+ H! Z2 k<!-- 改变下的弹跳速度-->
% V4 b1 y. V4 E1 Avar BallSpeed = 20;
3 @. a) K4 G6 U o2 Q( ?/ Ovar contentWidth;# k( n* A9 z9 h6 T
var contentHeight;6 s% t0 S9 y% M9 [: N5 H& D4 q
var maxBallSpeed = 50;
; t; R. L1 A1 U% Q) l6 z! Y* o# l" V& W' p* {
: @" C5 i0 B1 g wvar xMax;
( D, }4 B3 S7 `var yMax;! d' w9 H" q4 E& J" ]
var xPos = 0;+ u0 `& ?4 e5 I. l
var yPos = 0;. ?( S/ [5 |7 R% v+ L
var xDir = 'right';% m' c% }% V. M4 x+ D# Q8 v: q
var yDir = 'down';( _3 ~2 k g4 n9 u8 c# ^0 C H
var superballRunning = true;4 Y9 o3 Q' d& b5 g/ E) _% z, h
var tempBallSpeed;
6 F3 J- k. U/ S5 G4 }7 U) fvar currentBallSrc;
2 D* w5 D' _: E. T5 mvar newXDir;
6 Z/ I. T( z- ]' s" @var newYDir;9 B2 I8 I' H4 s4 o- E+ b
1 Y3 V& d7 |& p( N6 b" }. X7 Pfunction initializeBall() {
4 h0 b# l5 o. D& E& r if (document.all) {- i7 J" ]3 {0 p
xMax = document.body.clientWidth
: y8 _6 y7 [6 P- s* |8 h, t ` yMax = document.body.clientHeight" o* B, |7 `5 e. O
document.all("supertext").style.visibility = "visible";
3 K7 }. Y' G: _1 J) o+ p+ d contentWidth=supertext.offsetWidth
7 } U4 I& r$ E5 y1 u: ] contentHeight=supertext.offsetHeight. H7 Z4 C+ v4 C. X
}" H0 D$ [; b% } F: p4 X- o
else if (document.layers) {5 [' Z7 @1 j3 I
xMax = window.innerWidth;
8 f) E/ g, X2 [) ]; s1 u yMax = window.innerHeight;
, Z3 @7 ^7 O4 n contentWidth=document.supertext.document.width/ n* S/ q$ G: s" R8 D. y
contentHeight=document.supertext.document.height
2 D r+ W, c6 D: ^/ m1 A document.layers["supertext"].visibility = "show";
1 U4 N: ]2 Q8 N- |# `6 x7 `' G }
% M5 K8 \ s6 C+ f0 R setTimeout('moveBall()',400);
! P- Y& l! H8 ?4 S9 i% z; o2 c) S if (hidetimer!=''). B J2 ~% ]2 f+ F
setTimeout("hidetext()",hidetimer), ]# F4 X! t# @) _' F
}
* }4 O; X2 |+ Z* j
7 f7 s+ W0 ]$ s& Y% s* nfunction moveBall() {
0 T7 s4 S& E, |- z6 u, p, p3 W if (superballRunning == true) {4 N5 c% y8 f! `( d: Y% w
calculatePosition(); C- _1 O" g. Q' S- A* p! E
if (document.all) {
5 B+ p0 ~& w2 I0 D% |0 w document.all("supertext").style.left = xPos + document.body.scrollLeft;: p& b& k# r8 z3 k% H
document.all("supertext").style.top = yPos + document.body.scrollTop;* P2 d Q* @( V r3 }! n
}$ w" h) H* A1 l* s) a
else if (document.layers) {
$ V1 J0 M ]: D6 g7 [" m* b document.layers["supertext"].left = xPos + pageXOffset;$ J4 k/ d- \; |3 Q: F
document.layers["supertext"].top = yPos + pageYOffset;( Q; V* e: o! h7 G6 `+ Y
}
4 c" M# B0 n x- Y animatetext=setTimeout('moveBall()',20);; t% G6 @6 `9 g6 Q0 y* g
}
, P, n* C3 i5 v8 ? }
! J B" Z9 ^' R% D7 p* c( C
! N! q" F7 r. @function calculatePosition() {3 ~( Z3 I- Z {# O2 r
if (xDir == "right") {# y2 f$ A: v' n7 q$ P7 e! A
if (xPos > (xMax - contentWidth - BallSpeed)) {
8 B/ M, @8 i6 R xDir = "left";
3 s2 Q. X( @, e3 m9 L: V" l }
0 v4 M+ ]# ^5 \1 J1 _7 l }) l+ K D9 }4 H) R5 ?( f% x0 @' h
else if (xDir == "left") {( J7 e: ~" p9 }& p) b: M- M, O
if (xPos < (0 + BallSpeed)) {
3 p/ g5 _8 \7 O; j5 {9 j! p xDir = "right";' V2 V: H) H$ ~+ G
}
3 R% _+ {5 \+ y }
2 A Y' V6 R) ~ if (yDir == "down") {
" e2 r: F' O7 K& |. A0 y1 k) L! C if (yPos > (yMax - contentHeight - BallSpeed)) {3 w8 V' d; V( j, f" X
yDir = "up";# e# B Y/ W; L, Q8 r8 |5 {; e2 ~ e
}
5 Q# B% R* n" W9 `9 | P& _ }1 h4 _4 | {' g& J% P% Z3 W1 j/ j
else if (yDir == "up") {
" X) q6 P# y' ]3 |( W if (yPos < (0 + BallSpeed)) {
" ~. A# a1 I4 V! ]# ~3 q6 g yDir = "down";- v$ J% X$ A7 c& f7 t7 P! i
}4 x6 s2 m! s& Y( {5 L' F; Q- I
}; D- @$ ?2 d% P3 ]. B6 t- `
if (xDir == "right") {$ s; u# C& Z% k- I5 B" R
xPos = xPos + BallSpeed;
; t5 q: D' j6 G p: T( ?" K }
; e5 y- J# M P3 k. z- S1 m$ t else if (xDir == "left") {1 u; i+ h2 l. L. Y% j
xPos = xPos - BallSpeed;
. m/ r+ V1 o( W8 [# Q2 a; K }
3 e1 j0 C0 [0 B) ?. a; }6 j3 j else {
9 m2 Y$ `4 b1 d7 B xPos = xPos;) \9 W* C1 T# F
}
7 D7 L+ ^( p' H f if (yDir == "down") {
7 F H+ d( \* p6 ~ V# I! j; G" m yPos = yPos + BallSpeed;8 E, n8 ]( A: I0 Q! F
}
" ?, m2 c2 i$ n. K: [ else if (yDir == "up") {5 y% `% R2 G# ~+ M
yPos = yPos - BallSpeed;
, I5 V) r$ b7 G& _; i- O7 U }
7 n% m+ b7 X1 s/ {9 o else {
8 [# j% X4 q f2 k yPos = yPos;
9 N% I4 B( f1 f/ c }! K$ @. z! o. F2 q9 S
}
* S5 t. k$ P: N9 K9 W8 ^* E. I' n* V, q2 h! [# B! A# y
function hidetext(){# V b2 V# g2 ^# y% G, f1 w
if (document.all)0 A4 U$ i$ F+ ]
supertext.style.visibility="hidden"3 _, |* I3 s* s. [
else if (document.layers)+ W1 I& m1 C/ V# S& E; |1 R
document.supertext.visibility="hide"
+ }9 }& r! L/ Q5 H, TclearTimeout(animatetext)
! t) T! p8 X( _( P9 E: e; t% O# l}
3 K4 B. ~9 K7 g0 `" d$ c. T2 a+ t8 a; R2 w* ?
if (document.all||document.layers){4 U" [ x7 |2 N$ c
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
% i0 h9 Y& f3 W- jwindow.onload = initializeBall;
3 }7 _* ]( K* b5 ^6 [: hwindow.onresize = new Function("window.location.reload()");# ~: p8 V+ ^2 q+ m. Z1 o9 X# t
}
# s* R4 Z3 A% L7 _: \0 i; F8 R& K& i- S: ^" x
</script> |
|