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

|
网页之不断弹射的文字-特效
<style type="text/css"># L9 |, T6 d! T, A- L4 |( Q
#supertext {
# `' H: p, s" Wposition:absolute;. h3 y% n7 e6 ]8 p0 _# _
left:0;- G1 U. `7 M) w& l
top:0;
& ~+ Y, W: k/ x: Avisibility:hide;
2 c) O) V2 ~, |2 Gvisibility:hidden;$ u3 w9 A- E! [' Y5 R& J% J
}
' Z1 h9 U$ }/ x( p& _' e, h</style>. M5 U/ D( a. v0 V
<script language="JavaScript1.2">
' B) m1 U: G* y, z5 p& ?<!-- 改变下的字体的大小。颜色-->: I* \0 z" P- A6 A5 y9 e/ G
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
z1 S5 n& a2 M% m2 qvar hidetimer='';
4 j' i0 I) n) v4 m<!-- 改变下的弹跳速度-->
5 V) _8 X) K L& Pvar BallSpeed = 20;3 D2 H1 e2 A( G( H
var contentWidth;/ h( J+ j/ ?3 A5 X- c j, G8 T2 ^
var contentHeight;' f0 [7 m6 C4 r1 Y# u
var maxBallSpeed = 50;
4 t% ^" y2 V* a5 H6 E! W* T s; C+ t' u2 x O
) z! ^8 V* [# C6 fvar xMax;* |$ C% o! z& [+ |
var yMax;0 T4 U2 W8 s) e# d5 }3 g
var xPos = 0;: G2 N q2 r/ c" T! z8 X
var yPos = 0;0 R) `, j1 h/ W5 n* T6 A. ?% c; |8 s
var xDir = 'right';$ F, p5 G! O* `( F: @0 ?) R
var yDir = 'down';
: Q( ?( C7 B$ D# Ovar superballRunning = true;
/ ~; d3 C+ B6 z5 x- }# Nvar tempBallSpeed;
8 y" C5 o/ ^ Z4 pvar currentBallSrc;3 u( M% ^2 c0 Q: ^! ] u1 B
var newXDir;
% S- y/ J, p& [+ {6 {6 Xvar newYDir;
1 [" i* B+ g' ]. r+ ]
! A- z9 [: e w2 W+ l, ] G; a" }function initializeBall() {1 ~ t" u0 p0 |( \" v B% u7 W
if (document.all) { \8 M( J- S* ]9 N) H7 z
xMax = document.body.clientWidth
; |$ \- Y; c7 R yMax = document.body.clientHeight: d6 M$ H( Q* N& ^+ h. l
document.all("supertext").style.visibility = "visible";
6 D) J$ q2 S* v. d- S+ a contentWidth=supertext.offsetWidth
; ] ?2 h7 a" h- q# a contentHeight=supertext.offsetHeight
" y' ~' e9 g( f+ d$ _4 s, h; D }, s+ s0 E$ e; N: @! N
else if (document.layers) {
7 l8 J( g- }- |* _1 r/ L* M xMax = window.innerWidth;) H$ F! e/ e; G+ G
yMax = window.innerHeight;
+ I& L" [) D7 @0 g3 J4 n) C3 P3 s/ Z contentWidth=document.supertext.document.width: a% N1 ]9 ]& v- c1 g7 P: ?* O
contentHeight=document.supertext.document.height! P# V! a- H. w1 \) s% g$ F# V
document.layers["supertext"].visibility = "show";
2 W0 T. |# X' W' I8 z }
. g8 m/ j- A% W setTimeout('moveBall()',400);( `4 I9 m+ u6 T
if (hidetimer!='')8 p! N) `1 z0 y9 j
setTimeout("hidetext()",hidetimer)
8 R" {. V/ t L }/ I. L; _& h' F3 d. r
l6 ~# E% }6 h4 X
function moveBall() {
4 K( G; q$ w9 g$ L0 t if (superballRunning == true) {) d9 `8 Z7 {* L7 b4 B7 [
calculatePosition();
+ D4 w8 ?- ?/ t) g+ f: {: e if (document.all) {
' N' Z5 A, {$ L/ [& F% |/ X5 i. K document.all("supertext").style.left = xPos + document.body.scrollLeft;
% g$ p: v7 t" k4 C6 e& o7 Q document.all("supertext").style.top = yPos + document.body.scrollTop;
* Z0 `, t) h$ W1 |4 ] }
1 G. _. H. w) R: M2 } else if (document.layers) {# U* I! b0 E- ^3 `2 r
document.layers["supertext"].left = xPos + pageXOffset;
7 S! `: E/ s# k3 o) V, H6 k document.layers["supertext"].top = yPos + pageYOffset;
5 Y0 Z3 H+ m8 h, t n# v6 g& A" q }
9 Q; q( i1 u- S3 r9 r9 C) a9 D2 B! h animatetext=setTimeout('moveBall()',20);
" P6 U$ N1 I: z9 l z" { }
, X8 `6 U" N( @- o2 G, q }& ^+ B9 [: C* n0 p" t5 m
* a0 f" l1 d$ L" J1 d
function calculatePosition() {
, |; @& z) K0 z) F) q if (xDir == "right") {
+ d6 k1 i: }, x( ?5 r; k& v if (xPos > (xMax - contentWidth - BallSpeed)) {
+ A5 \8 O8 q% A7 C" @: E xDir = "left";, t0 I9 S% L: |; b
}
9 Y& i/ p# P% T6 A h% _ }
! H; C& J0 I: }. K else if (xDir == "left") {
) J; X9 f. L0 g if (xPos < (0 + BallSpeed)) {( l, a) T3 C. }, i6 [) X
xDir = "right";/ Q* M% o; p) d. C( [
}1 b4 o3 g( i5 N( Q% C- h. `
}. T! r% F9 e1 k: q8 K' m+ _3 _! Q
if (yDir == "down") {2 M' C; c z( \) ?. `2 N
if (yPos > (yMax - contentHeight - BallSpeed)) {' w) t% ~ q! N/ a; @
yDir = "up";
* z' q+ y6 [0 ]- E }
! v& V$ a) Q; R* b' Z W* } }2 \# p: C; ?) d2 y9 a! }. e- ^
else if (yDir == "up") {
& K) `6 _3 f- N. k E' l if (yPos < (0 + BallSpeed)) {
" J; O G/ l$ g1 ~1 P" ^ yDir = "down";
9 ]4 X! f, L! Z6 ?0 B1 ?7 e" M }/ }' j3 M6 Z7 F8 l5 B* O
}/ b# D+ `# t) I3 j! F7 F7 D Y
if (xDir == "right") {
7 ?* _, @ f0 U F. w7 w& @9 F$ h xPos = xPos + BallSpeed;3 z8 B9 u+ \9 }+ o9 x- C# U
}
: t, i% a+ l7 y9 i6 |$ Y. y, l7 F else if (xDir == "left") {. q% w3 Z; _' u. [
xPos = xPos - BallSpeed;- O g* d/ N" j- g2 t) l& n( w
}, M3 }" r) v. q" L' J: ^
else {
: [) s h+ K) O xPos = xPos;5 u$ D8 C; w( Y1 t: {+ I0 V; O1 p
}/ j' k4 e# t' v, q/ C7 y) A( D$ t, `
if (yDir == "down") {
3 v$ r! N& ]; c. i4 v* x+ ]3 X yPos = yPos + BallSpeed;
' Z J: ~3 q- B# _0 |- I% x }. C6 t) W* Z* e& M
else if (yDir == "up") {( I3 ?% I x' o0 K: h& ?
yPos = yPos - BallSpeed;7 {2 u6 P" W6 `" N5 c3 R
}. B1 W7 j( U1 m+ U
else {
, @8 \4 Y" r7 p |1 G$ X5 o+ y# Q yPos = yPos;) r6 z; s& S: @& _; O& Z8 z2 d
}
& @* I& s6 q7 ]0 ? T4 u }
1 m- b1 C3 h& `$ ]; I' |/ O1 Y- g4 h1 p3 p2 f Z* G/ I9 R
function hidetext(){" m w0 x9 n9 ]3 F7 C
if (document.all)
' |8 z. M0 {6 _0 w0 Z' W+ Gsupertext.style.visibility="hidden"
# [6 e6 k" i( b5 _+ l1 h$ @else if (document.layers)* T: p# \5 h" p) F5 P; ^: _
document.supertext.visibility="hide"& ?1 Q2 L8 S r3 \+ S3 R' o! D+ z
clearTimeout(animatetext)' z8 x5 Y2 M* r5 P6 i8 g0 W F
}8 s3 R* ?! \0 F9 k2 h
! e3 n/ j/ \) @# y" K
if (document.all||document.layers){$ r3 w: h. R& |+ v
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')# W' `# w% d, B9 u/ V$ X1 v
window.onload = initializeBall;
+ M/ Y5 n% ~2 o' F4 x2 L9 `window.onresize = new Function("window.location.reload()");
% L" N `8 n% s" y; n# y}- p# M' \% ?7 O2 Q$ R7 r% s: ~
}% [$ Y2 Z4 d0 w C8 A8 F
</script> |
|