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

|
网页之不断弹射的文字-特效
<style type="text/css">
" ^0 f5 p3 b1 A W8 ]) m- p#supertext {. g5 A9 o9 {# J; ^) ?
position:absolute;
* [5 l1 P) N5 F4 r/ M, p/ [left:0;
$ m$ ~9 S- d t6 I2 \top:0;* a3 g/ b T8 R q7 R" U0 s: X
visibility:hide;
6 k3 i/ ~6 P, @/ o- s& wvisibility:hidden;
- T5 m* [- o: C3 ]: N}
' k# j" F9 R7 O! m</style>
" j# u8 K2 Z3 a, C- K6 y<script language="JavaScript1.2">' z* ]! z% {+ v" w* B, |" J
<!-- 改变下的字体的大小。颜色-->! a1 d4 ~' i8 n# ~" L
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( @ ~9 d) t0 O% S' e! D+ t9 _* Z& Kvar hidetimer='';
6 E0 e! s5 {# p8 r' S& l<!-- 改变下的弹跳速度-->
! C# ^7 U$ L. [$ X3 nvar BallSpeed = 20;
8 Y# _3 h" q( p: T; L' Zvar contentWidth;
0 P: e% {" D" A; y* Q2 s; P" q5 Fvar contentHeight;
4 e# V- o4 z/ K. _. A& W( Fvar maxBallSpeed = 50;
2 q& e: T3 A: k- v6 x2 D% k9 q
7 Y( v- _9 C0 ]) R; l2 x+ L: v0 q- [6 } X0 ^$ P- @) ]
var xMax;% U9 m! |# B4 S+ h5 u: W8 g9 n8 Z: \
var yMax;
) J# x' x' y) i. qvar xPos = 0;
/ g2 u, f% P5 i6 evar yPos = 0;/ p% G* S. U: G
var xDir = 'right';: v: L- @& R( [ ~: ^
var yDir = 'down';+ u. I& h9 ]: C4 C* r
var superballRunning = true;
: c+ g5 Q Q/ ]8 Z9 r* yvar tempBallSpeed;/ F3 t7 ^2 M& N/ G0 {
var currentBallSrc;
( x! N' u! v/ Q$ nvar newXDir;
0 W( ]) ?" f: ]. p& \var newYDir;
|$ v9 v$ ]. ]: X( n0 l# ~; \ Q" T1 k6 X' u; C/ S6 f
function initializeBall() {) S& ]5 T3 W, a% U f/ [# r, z- @
if (document.all) {
; y( T+ c4 j" \5 r) N' T% x& H4 f xMax = document.body.clientWidth6 t0 Q9 u6 X7 k& z* z* A
yMax = document.body.clientHeight
' a' @( w9 x9 ?* c/ C% d5 r$ X document.all("supertext").style.visibility = "visible";
9 ~7 \, z9 L' m; V* r- D6 I contentWidth=supertext.offsetWidth
3 _$ ^. Q+ j: J6 M' W* Y9 H contentHeight=supertext.offsetHeight
% \$ ]% u1 \. ?2 u* q# V w }
+ g& E& [! }, h- o* _; p* N" F" l else if (document.layers) {4 @" I* V8 ?: x8 y( l
xMax = window.innerWidth;8 L8 A4 o/ ~5 t
yMax = window.innerHeight;
* Y& L( Y% ]$ B& `0 R0 z contentWidth=document.supertext.document.width* r, U+ T5 E# c5 ~4 }. ^ v- M4 v2 @
contentHeight=document.supertext.document.height
7 |+ b) u G- ^ document.layers["supertext"].visibility = "show";' u9 n) ?5 o4 R' t# Z E
}
9 m! s- D% w. E/ P6 z7 u setTimeout('moveBall()',400);
2 k7 p/ w. }# E# l N$ b0 X if (hidetimer!='')
0 |) S. ]% u M. U' s) C setTimeout("hidetext()",hidetimer)
W( s7 X; D9 z4 i7 ^ }! W( u! f" e; ^0 x. @' B: q
% l' C# k4 v1 V
function moveBall() {+ C7 m! j& m% _4 l
if (superballRunning == true) {/ N& U L6 X( j C% }
calculatePosition();' |; a& q6 x8 S/ V4 K# ~
if (document.all) {
. @5 h$ S( _6 d- [% {! ^8 A document.all("supertext").style.left = xPos + document.body.scrollLeft;. R+ R( j( H. c4 {
document.all("supertext").style.top = yPos + document.body.scrollTop;8 _6 W! E. q4 O: d
}
$ @* I# [3 f" Z else if (document.layers) {
8 ?0 I' j1 d8 o$ F7 s2 c document.layers["supertext"].left = xPos + pageXOffset;( b" Q: U% y: U9 `5 Q O+ n( L8 y
document.layers["supertext"].top = yPos + pageYOffset;; k4 m9 g/ B9 F9 [5 L2 a" @
}/ {, s/ n0 q0 a' s: g2 t
animatetext=setTimeout('moveBall()',20);% S5 P! L+ l* L( M1 D( f( B# o
}
3 o# ]. e8 F! V" c f- X2 B. [ }
! P' l+ Y I* B O% x- r
" G8 B9 v8 T4 H \ Q* i2 J/ ffunction calculatePosition() { V5 D+ B; w8 g4 ?# f) O6 d
if (xDir == "right") {
" }. T* Z, S2 u+ C) g' u; I if (xPos > (xMax - contentWidth - BallSpeed)) {7 C( f0 I, c- h% z2 y' R
xDir = "left";& q7 [/ _# W9 |: ]6 @! r
}
H8 v$ W+ L" n) ?9 B& X3 E0 v }
6 Y4 k1 q! @) |3 A else if (xDir == "left") {. |! _3 c7 m& o* u3 @4 d$ B
if (xPos < (0 + BallSpeed)) {
8 _1 I5 E3 h3 t+ ?4 z# k2 A xDir = "right";0 J! F' q) H, d8 Q% e- L4 O+ d
}4 |; \% ]7 Q5 o' Q5 N) T
}
/ i5 E. Z( ^" R% ~% U if (yDir == "down") {, A! q0 M2 O2 i. B
if (yPos > (yMax - contentHeight - BallSpeed)) {
9 a1 T: [1 W( G! b yDir = "up";. D1 e% v, H' _) Y5 M8 v8 h4 q
}6 X9 F. D: o2 X6 K7 V: a& J; V
}; \. P8 G0 x; R
else if (yDir == "up") {* [' n6 r/ P( c% T, F
if (yPos < (0 + BallSpeed)) {
0 I) y5 Y6 g) A/ u! ~% T yDir = "down";# T) ^! x! W6 N( ]5 E. G
}0 V7 P! j, ?9 f$ j6 G
}
9 [7 T9 O- x* w ^% c9 o- i/ w2 P if (xDir == "right") {
8 J# X1 B* X4 v+ x( E- L! c xPos = xPos + BallSpeed;* B+ [0 F+ f) n- q! p. j" ^
}/ W# m: P# C+ \
else if (xDir == "left") {
2 G G: ]* D' w. ] xPos = xPos - BallSpeed;
% J- L1 ]+ U6 m }
6 R6 ~! _" g( o- f5 L1 n% F2 {) s) o else {
% r: q# G2 t$ R0 K3 l xPos = xPos;
4 m8 a( A$ q+ m1 @. m }
0 u V0 ~9 A" d7 C4 ] if (yDir == "down") {
) J+ K6 s1 p$ M( ^& o yPos = yPos + BallSpeed;8 @8 N! ~- X; B* S5 I
}
2 t8 q. j8 y3 S8 z: V/ s. q else if (yDir == "up") {4 b Q% E) {& a' R
yPos = yPos - BallSpeed;
" e5 z% d" A# M6 ^ }
1 S9 t5 v$ G: Q, A7 T/ f else {+ ]& ^9 G/ W* I6 i
yPos = yPos;' S/ Z7 L: A. a$ \
}" X( d0 l/ r0 h+ k1 w
}
+ c; e& S' j6 L( Y
0 I% o* M: C+ T+ e& m& Pfunction hidetext(){
8 ^: p- I( r' ?8 Q% Vif (document.all)- f% J* L, Y# N# A7 L
supertext.style.visibility="hidden"
, u1 f& a& N- a1 C4 R* E0 ]else if (document.layers)4 R, q0 ]6 f) S. T+ V7 F
document.supertext.visibility="hide"
9 g. U" X* ]( q9 r+ n1 BclearTimeout(animatetext)
9 ]7 d' k# I$ H& }; }' ?}
Q9 V. u0 Y0 ^2 |1 J9 ?/ L
! Z" U9 k+ v5 _, a5 A- z( _9 @+ jif (document.all||document.layers){
; |! _1 Q1 ]8 f; }' q5 {& f/ {& Bdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
+ Y) t$ W+ A- ?' {1 Pwindow.onload = initializeBall;) U% K* a `1 f
window.onresize = new Function("window.location.reload()");
* T5 G* _; T3 o0 k! g( v}
2 Y' X% A% z4 R
5 j* w& U. d' M</script> |
|