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

|
网页之不断弹射的文字-特效
<style type="text/css">
& r1 ~( o) \& ^! F' l#supertext {
1 } f1 _+ m- l% m, P0 ~8 O1 Mposition:absolute;) H6 a! c, r! f' e9 [! L( t; W: l
left:0;
3 D& R8 @0 l6 X* y% ftop:0;
" C3 X( w, _; s2 {4 ovisibility:hide;) ] I; Q$ s4 c
visibility:hidden;' j; A7 {. v0 i( T/ Q7 W
}2 r) N! L4 o" c3 |6 x
</style>
; A" U) z& q8 ~<script language="JavaScript1.2">
2 g) j; t. R( f<!-- 改变下的字体的大小。颜色-->
9 Q2 s7 o0 @ Cvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
4 j! N x6 b/ I( K: |' Wvar hidetimer='';3 t0 C1 Z* T, i' I% A; s
<!-- 改变下的弹跳速度-->7 X3 l" y+ }0 X$ O5 T
var BallSpeed = 20;7 m- k; g* o2 s7 O8 k8 X+ I' l
var contentWidth;
- a7 B' P, Q+ C4 o$ J2 ?# Qvar contentHeight;, U6 R" _. t2 i* b* N, Y7 X# a
var maxBallSpeed = 50;
# {' e/ \" J6 z& S3 i [
" ?/ ^- e" T N. y8 V1 D( K6 W0 B
8 P7 S ]4 r: y3 g1 j* P2 `var xMax; g/ W9 a+ h6 Z1 [* ?2 J/ D
var yMax;
" W2 b- S3 Q$ Y4 ]# D, i5 s+ Avar xPos = 0;+ H$ a( |8 ~6 ?/ l6 s. T, {" b
var yPos = 0;3 a& `0 `0 f& y% H2 `) h4 K- H
var xDir = 'right';
7 J; V) b0 \; G3 n) n4 Xvar yDir = 'down';
]) B; {1 j/ g7 d5 bvar superballRunning = true;9 T4 _3 _4 u7 L- y' S0 y) U
var tempBallSpeed;
8 t& E: o& ?0 @& Pvar currentBallSrc;
; A0 \% T4 H( d rvar newXDir;
8 B! o) N7 o* y: `! |( Xvar newYDir;
& n6 @2 s1 r3 Y u' l9 w+ D/ z- ^% o/ u
function initializeBall() {
( [' C" G# j! n5 u$ s2 u$ ] if (document.all) {
# V5 F9 B) _) n/ I xMax = document.body.clientWidth
, J9 e" t; e5 L8 v* a" d, e9 Y yMax = document.body.clientHeight$ G2 M. A, v% j/ n8 Q9 x
document.all("supertext").style.visibility = "visible";7 I1 J8 S& v* z0 r& o7 J( s
contentWidth=supertext.offsetWidth
. m# \* w: ]$ F contentHeight=supertext.offsetHeight" M3 E' |6 f. l
}
( F3 N' e% k4 C n$ J4 E else if (document.layers) {
5 l2 ?6 f" i/ F# N xMax = window.innerWidth;
% ~6 p) T( O' J yMax = window.innerHeight;6 w2 R$ @3 [+ }1 H" W3 e
contentWidth=document.supertext.document.width4 A) Z3 @3 \- a
contentHeight=document.supertext.document.height
6 K+ F, d* @" d4 i9 ]% w document.layers["supertext"].visibility = "show";8 \/ A1 v5 U7 L9 F
}: p2 O/ K1 Q1 Z( Y( ?
setTimeout('moveBall()',400); u6 ^& r" l" z1 H, w, t) i/ l
if (hidetimer!='')
4 ^; T$ Z; t( L8 { Z) ~2 t. f7 ` setTimeout("hidetext()",hidetimer)" e6 k9 y+ M& P+ H3 Z1 y
}
: ?5 x8 ~3 X) d% G9 U3 b. k
, \8 m/ Y s) j+ k4 pfunction moveBall() {6 b; s |# m4 V
if (superballRunning == true) {
! x8 Y3 y4 u7 V- L calculatePosition();
9 q& U; R3 S& }0 g) _4 t% j3 v if (document.all) {
- k& z0 g! T* }& b document.all("supertext").style.left = xPos + document.body.scrollLeft;; n4 [7 C, h, \
document.all("supertext").style.top = yPos + document.body.scrollTop;
) r4 S3 n X6 Z9 w/ ~# V: q% `% h+ ~ }
; d! I9 [- f, M& ?+ X else if (document.layers) { _6 M* |! Y8 f4 Z
document.layers["supertext"].left = xPos + pageXOffset;, D! V/ |8 C$ C* q; b3 U0 V
document.layers["supertext"].top = yPos + pageYOffset;
" h9 b( w# @+ }* a( ^ }
7 m! W8 j% O, J2 H6 G5 ~" { animatetext=setTimeout('moveBall()',20);. U6 }1 Y& M7 F3 w) d: }
}3 A4 V U" J/ }7 `9 m( m0 J
}4 |2 c: f% G: @) L- O2 M# h
# R7 F/ D3 M+ h4 D. z; u
function calculatePosition() {
1 ~# m G5 m1 S4 r i7 c if (xDir == "right") {
: w6 ?& L- T; l1 f! u, Y if (xPos > (xMax - contentWidth - BallSpeed)) {
- g* S' [& G f# p" A8 Q xDir = "left";, x: v( M$ D' h' k7 L
}/ k% _& w$ z; a X
}
' r% m6 n8 c. L) f$ ]8 Z else if (xDir == "left") {5 h4 Q' Z5 Z7 A- }" m7 @$ z
if (xPos < (0 + BallSpeed)) {
6 f e/ u$ c7 [- t9 u9 v xDir = "right";
7 [9 v* e/ z1 W4 D+ |. x v }
3 j: d4 S F/ K }
1 I- h3 t. Z( X1 K: A: W( _- ?$ [ if (yDir == "down") {1 u2 J% B& i5 M
if (yPos > (yMax - contentHeight - BallSpeed)) {* f+ O+ g5 n7 P. k3 ?0 t
yDir = "up";
i( o9 Y0 v9 B; b( N# D }
& a, a8 j5 V1 V. j1 F: Z" R% k! {9 v9 x }
( ~2 v! R* B" o6 i; ] else if (yDir == "up") {
6 w/ @# ~( K8 o if (yPos < (0 + BallSpeed)) {
6 }1 u9 V) f6 L- J f4 s yDir = "down";
5 M- l; s" U1 i5 M7 }( V }
! k& ^/ A- |! e0 C6 l }
+ s7 v$ u G* ~0 l if (xDir == "right") {
2 Q: {- m% t" k) {; c2 _7 U9 a& | xPos = xPos + BallSpeed;. F v* e# Q% T4 L# [
}
1 m. u9 W2 l& U Q. W6 K: k+ @% r else if (xDir == "left") {3 @0 P/ m; W6 D- i1 w, B$ u8 p8 B7 g" L
xPos = xPos - BallSpeed;
7 \. J" E, E6 K. y. X' H }
# R$ P/ G4 H/ A7 N; W# } else {" ?& ?5 r s+ x4 s8 Y
xPos = xPos;0 g! F) i& X* H+ [
}
8 A* e$ R& r9 I6 I if (yDir == "down") {- q. R3 ~3 W3 F- W+ ^
yPos = yPos + BallSpeed;) s' ~9 z6 v' s! Q+ f2 Y! T
}& V/ p6 g. M+ U, a% d- D! u
else if (yDir == "up") {* j: L, F T8 c! z" s: H
yPos = yPos - BallSpeed;% L: e! z5 q5 }0 A5 c- t" c
}" D/ R4 V t# J( }
else {* |$ Q5 `' f# L7 q8 G3 i
yPos = yPos;
6 ]7 {9 G5 H6 E! @ }
% H+ T) n4 \$ B$ D( ?- ]. }% o/ r$ m5 } }
; e$ I k( i+ E* k1 v5 }4 M6 w
& o4 H3 T' p* S! a' k- kfunction hidetext(){
7 b- p. c$ C2 x% d6 g9 G" ?! p! Fif (document.all)( t* |, c% b* P1 U" n& d
supertext.style.visibility="hidden"
( E: u5 R) b, C/ }else if (document.layers); q ^/ `- k5 ^
document.supertext.visibility="hide" [0 v, n# A1 \. z" ?& s5 W0 Z
clearTimeout(animatetext)# [! T; h4 \) D9 H/ R4 K+ E, J
}
+ }' M. N& a3 H0 T
7 J+ `3 \0 Y5 i& w# Kif (document.all||document.layers){$ p, B5 u% x" X/ j! B
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')/ S! C8 B: }; M
window.onload = initializeBall; w2 Y0 E! m: F
window.onresize = new Function("window.location.reload()");
1 ~$ t+ `; o1 N( M4 J2 Q6 Q9 ?# p}
9 c, S0 F1 d+ e8 Z- M/ |! V# x
0 u# n0 d: P/ ~+ ]. F</script> |
|