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

|
网页之不断弹射的文字-特效
<style type="text/css">
$ `# h- p0 z+ {' r4 F) S#supertext {% }! B" `' D5 \ ? \! C3 N2 n
position:absolute;
7 ^/ k( k- X, ~2 e# D8 l6 h9 w# e1 \left:0;+ k- c+ T2 e; a1 w5 @
top:0;
3 F c U, y4 ~+ X6 c; ~# tvisibility:hide;
' c. n% E* P h& S; O3 X [# Evisibility:hidden;
3 Y+ U" M- r# y1 r0 f% {}/ h9 o ? u, e4 b
</style>6 C# i3 @+ G2 } o
<script language="JavaScript1.2">% k0 |- Y4 E- S/ _- Q$ Z M
<!-- 改变下的字体的大小。颜色-->
' i2 U' R0 Z% Z% `. y# s8 gvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
6 y! q& G+ n x4 M; u7 ]var hidetimer='';# L" s% v/ O7 }8 Y" Z3 u
<!-- 改变下的弹跳速度-->
6 U" J" d$ e) L+ D3 |0 |+ nvar BallSpeed = 20;
; e& w, l0 k/ f \: ^& J, X0 ~# {$ p avar contentWidth;
8 D0 F, I+ U9 b9 E! Cvar contentHeight;- O. w* h$ G1 ?! u4 H7 [ L
var maxBallSpeed = 50;
. ]/ r2 k, }" K2 U+ Z$ c7 g' G# e/ V) {7 a5 a; u+ I$ S; Q5 D
1 H4 i( h& g- h% {9 U' M3 s% uvar xMax;8 H# E- k* A- Z. H$ [2 q
var yMax;6 v0 o- G4 d' C* H* k n
var xPos = 0;
7 Y9 g$ W7 K% rvar yPos = 0;
( I" `0 A+ Q& E$ u. zvar xDir = 'right';
$ l) ?4 r( g: e' \" f& z& Dvar yDir = 'down';
1 E" f4 m. |5 F; ^) c# Cvar superballRunning = true;' ]* f' B/ J! }, m1 O6 s! A
var tempBallSpeed;0 b* W9 _ v9 H! s4 _% M
var currentBallSrc;
E% C) x' k0 s7 t+ r; avar newXDir;
R9 T* \6 y6 G+ G |( Dvar newYDir;
& i5 c O- C/ C0 S6 _- X
8 U/ p, J, f) e7 ?' E5 e2 Ffunction initializeBall() {( v) ?$ F9 _' e0 J+ p+ H7 B/ u
if (document.all) {
6 W1 U. P, r, G) f xMax = document.body.clientWidth
, S4 T! Y$ ^. n ^" M7 a5 ?- } yMax = document.body.clientHeight
& I6 r3 z4 l9 ?( r* c document.all("supertext").style.visibility = "visible";
9 p/ ^8 q$ e- @% W" } contentWidth=supertext.offsetWidth
) h( Y# j- N9 E contentHeight=supertext.offsetHeight" n) J/ e3 r9 c0 U& m$ k& l" Z
}# }! g$ x' b( \. N0 Q+ I+ q6 p
else if (document.layers) {, h* `' h+ J) |+ Q a5 j
xMax = window.innerWidth;5 s, B/ M% e; L8 [4 Q$ l+ R% \
yMax = window.innerHeight;; x' `! u* }7 T. L% `
contentWidth=document.supertext.document.width
! \0 c& B% K3 W" Z# H8 _ contentHeight=document.supertext.document.height
* L. |0 B. l! s$ U+ u2 o' P' f document.layers["supertext"].visibility = "show";
" l E$ \2 m+ p( }! c }( r# S9 y" V5 n/ }
setTimeout('moveBall()',400);" b ]2 a' c% {( {7 m: n6 Q
if (hidetimer!='')
7 K2 A1 D4 i' x5 I. @( L6 ] setTimeout("hidetext()",hidetimer)
: B* p; |! K$ D% Z! c% W1 q/ |1 G }
; y3 k2 B1 `( x5 H, t9 G3 O
9 a# |; s2 h! ~; u3 x, I: vfunction moveBall() {& x& L7 b9 H% }, t4 n- q6 v- @
if (superballRunning == true) {
, R z( _( g$ }: g6 O calculatePosition();
& v$ X# O6 A1 L" A& ^ if (document.all) {
7 P8 K! H9 |7 T, G6 f document.all("supertext").style.left = xPos + document.body.scrollLeft;' o$ e0 `7 c! e) d( U) y0 w
document.all("supertext").style.top = yPos + document.body.scrollTop;3 u {* ?: J# H* @6 ]; ~
}7 }8 z+ U, p- b2 \4 g
else if (document.layers) {
6 L, [# R# v0 L* n3 ]0 Y document.layers["supertext"].left = xPos + pageXOffset;$ r$ z* A h, J4 X6 J
document.layers["supertext"].top = yPos + pageYOffset;
' t a. G: F9 c+ @1 e }
6 M+ `. w1 W: B7 Z# I% O7 E& d animatetext=setTimeout('moveBall()',20);5 X9 P }7 O! [
}! d( a m7 p; {/ X% I2 i
}
/ b5 U j8 o- M4 E" I# g1 e6 A! l* T# X
function calculatePosition() {
5 {3 B/ ~. Z5 g. O7 v7 s3 M if (xDir == "right") {4 @ g) Y- E: i! f: _
if (xPos > (xMax - contentWidth - BallSpeed)) {0 N/ Q3 {( L3 d( x6 f
xDir = "left";- g. H" {$ f; g1 g- O* k4 t
}
$ T4 B, g/ ?7 C% T }9 G$ N7 @1 N0 ~
else if (xDir == "left") {
6 S! n) Z/ q t2 s' I0 D if (xPos < (0 + BallSpeed)) {
6 @) f0 D; H8 K9 S$ L xDir = "right";: x' X, p2 ?6 n% P( {" b1 K: n
}; |: K& L. {& C: p1 i' @
}
) ~" r6 O/ V% q2 o if (yDir == "down") {! o# j$ m4 n) U+ g' r% Z
if (yPos > (yMax - contentHeight - BallSpeed)) {
; {. o" @% t4 J. ~4 p$ W- ? yDir = "up";8 O+ m& F( q/ |
}
$ Z, @) r3 h* \$ `. E& X }
4 l/ p4 z" \2 d else if (yDir == "up") {
" p4 X, v w1 e" H1 U# w, s if (yPos < (0 + BallSpeed)) {6 l, F5 Y% \4 {
yDir = "down";
4 }" f/ n. N7 b3 I' K }
. m( F% R- p% b' m, z }2 h# _ u; v$ x0 K) Y; S
if (xDir == "right") {
) F6 S" }! {; I3 S2 J xPos = xPos + BallSpeed;
* M5 v2 a4 Y" o) l }
: ]6 H- P: N7 p% z7 u- s else if (xDir == "left") {* V3 }5 K! U+ g. p. A
xPos = xPos - BallSpeed;5 B1 v9 z* \1 K4 D$ b7 _4 J
}
! D2 N4 L' H9 O else {4 K0 ~, Z5 [, g5 g' R
xPos = xPos;
~$ g, c7 z5 @" j6 [% W+ u' g; s }
8 g" j6 _# ~. `5 @) a5 M; x+ a: V$ U4 x if (yDir == "down") {
! P4 i) V7 A* l3 O2 z2 Y5 d yPos = yPos + BallSpeed;2 ^' B5 U Z/ A, U
}- q: @3 K4 |; z4 M2 I
else if (yDir == "up") {, O0 {: Z0 X3 F2 Q) X9 D
yPos = yPos - BallSpeed;4 ]/ B/ a+ }! @/ S' s4 P# u6 G) c' g
}
' P3 @& K: }7 h" R! | else {& R* @4 @$ V2 k& V Q6 [
yPos = yPos;0 F0 b5 L0 C$ `3 _3 _
}
9 ~* ]) y+ q1 \* I% R- ?8 o }
2 ~3 P4 b. v8 y& x. A2 G; D& }: W8 q6 i* t: N% _
function hidetext(){
) T3 o; y0 i0 B+ ` k u h; _5 F6 ?- Eif (document.all)
3 E* W2 f0 [( r3 ]5 hsupertext.style.visibility="hidden"
' c+ {/ H% F+ G8 b& E( l6 velse if (document.layers)* _7 |$ F$ \: B; J" B4 p4 s, a3 @
document.supertext.visibility="hide"
; D$ _8 v7 M- U; VclearTimeout(animatetext)4 S5 S% g/ O; z# k5 O
}
& W6 Q; A9 A0 q5 V6 L, f0 l5 q3 X8 x2 H* r3 J
if (document.all||document.layers){& l# A: L" k1 \2 z! \9 b- }8 b& p
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
* D7 Z" {, n$ ~! Owindow.onload = initializeBall;
1 A1 z* W+ G* Wwindow.onresize = new Function("window.location.reload()");
. i' K$ m; U3 r4 |' t C}% ~" T4 r0 k, g5 M+ F: ]
4 A4 [' M. _. X5 p</script> |
|