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

|
网页之不断弹射的文字-特效
<style type="text/css">
7 s7 M3 F; ]. l# y. C$ c5 M' N#supertext {
7 ]( r6 X- G6 L% Iposition:absolute;: Z3 N% {/ z8 j6 T" V+ h8 ~& B5 O
left:0;
! U# E9 F/ c2 l dtop:0;
7 D- ]$ s- c- J2 R# m$ jvisibility:hide;
0 J. J |. b. }7 m( Cvisibility:hidden;
: j! T6 B ]; f}
9 a, |$ G) D) R+ x( Z* v: I6 m2 O</style>( w1 n- A, e3 ^; i1 ~
<script language="JavaScript1.2">
6 g+ n4 j. [0 u7 L/ b<!-- 改变下的字体的大小。颜色-->
6 U' {5 A- @% H/ D* fvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
4 o- ~& E% Z) W$ e; Ivar hidetimer='';
1 U: M9 O& I5 `4 _: w<!-- 改变下的弹跳速度-->- g! v! g6 Z* C6 {' ~% @* L+ [* E* R
var BallSpeed = 20;
( Y, d; D) P) {/ p! R1 R5 D4 pvar contentWidth;
- i$ K! I" z7 _7 t2 }+ j! Pvar contentHeight;
. B0 ~5 i# _) g u! F% T' y' xvar maxBallSpeed = 50;' p( i4 v- O' m
2 P+ e2 J" r% |& Z+ m' e
9 e1 b8 A) j8 F
var xMax;
% _$ F* y; h; @/ Jvar yMax;
& q& a3 R0 f5 @6 s/ e5 jvar xPos = 0;
1 q. O% [$ v7 W) J6 X: uvar yPos = 0;
5 F ?1 g! n3 Vvar xDir = 'right';% _. e0 J! `- N; _! |( T, |
var yDir = 'down';
4 s; {7 Y) S8 P# O. ?. w& avar superballRunning = true;! L+ k9 ~& G6 q
var tempBallSpeed;( U8 F3 {3 M7 B k8 W
var currentBallSrc;9 q% ^( v0 d8 L5 b# c, }8 [
var newXDir;. r' z) g* L5 g$ o9 X! M6 M& W& M
var newYDir;8 e$ {% i% l/ Z! p
& [$ y7 o9 q: a3 P5 L
function initializeBall() {( s$ J8 `3 w4 D- Z5 M- y
if (document.all) {
& {, Y+ [2 v* U, f4 }+ l( \. q xMax = document.body.clientWidth
6 H ^5 G! U% |. { yMax = document.body.clientHeight4 a9 Y; T3 y/ O8 s' N
document.all("supertext").style.visibility = "visible";
5 M8 Q- B& D x4 c contentWidth=supertext.offsetWidth& L% E" d. x4 G. v5 Y/ z0 y
contentHeight=supertext.offsetHeight9 h4 f9 j5 V" H3 J" ?+ H
}
; k, s Z! S! x7 q/ q5 t else if (document.layers) {8 G& p2 m, P) m S$ k, i
xMax = window.innerWidth;3 r* Q& C1 k% ^5 n* N% Q
yMax = window.innerHeight; l% ?. D1 W2 S9 G& D8 A2 E
contentWidth=document.supertext.document.width
. t" Y9 F/ p$ \, I% c* B contentHeight=document.supertext.document.height
* g* W* R4 j) J document.layers["supertext"].visibility = "show";: G8 i# Y9 F8 r
}
; d: Q+ @4 q; x' M! V R6 _ setTimeout('moveBall()',400);
: Y, d: }: e5 X9 j/ D# m+ v if (hidetimer!='')
- U- R6 U1 h% G; f7 P" G setTimeout("hidetext()",hidetimer)$ c/ @) ]5 ?1 Q5 s r
}, k4 F. d; U" r5 j& b3 v$ ~6 P
. V v& x w3 L2 E, H5 Nfunction moveBall() {% G) ~+ [# W% E% ]
if (superballRunning == true) {( {5 ?8 Y# i3 ~4 @. T4 t7 ^
calculatePosition();
- C# ^: u, t9 f) \* ^* T. S b if (document.all) {
5 M1 U, |! n+ u' h* x- K9 c document.all("supertext").style.left = xPos + document.body.scrollLeft;2 ~/ h8 P7 d2 n0 U
document.all("supertext").style.top = yPos + document.body.scrollTop;
- ^# Z$ a4 V, s }. U0 f9 Z; P5 A, S& q' P' ]
else if (document.layers) {0 }! P: ]* Q* J# }& L! F6 u3 J
document.layers["supertext"].left = xPos + pageXOffset;
5 }5 E' U: T0 c document.layers["supertext"].top = yPos + pageYOffset;
: w [, ?$ {! r9 y: X; j }
/ f4 F7 V# q/ w8 B animatetext=setTimeout('moveBall()',20);6 _5 t2 M+ y* ~$ k
}* t& {: z! O( u$ w, G
}* N4 k. K: r$ c6 F# K) o8 }( r
% O* Y5 y; a, X
function calculatePosition() {* [# z) O# _, n' S" O( P4 Y
if (xDir == "right") {; ~5 x9 _( W! {2 a9 [/ T
if (xPos > (xMax - contentWidth - BallSpeed)) { w. z/ i. O4 E
xDir = "left";
" {" O, d/ D3 R$ _ }
2 Y" C k; g K5 K& n3 c3 ? }- I- p! c9 m" g0 E9 C
else if (xDir == "left") {) a/ {: M# @; p2 w2 i! q
if (xPos < (0 + BallSpeed)) {
9 [$ C& z1 ^# `+ D* q" N$ W xDir = "right";
3 r# h' i v8 h1 N" i' a' L) J }: y+ u6 |$ Z4 P. E! q) T u
}
# N; U3 |5 g8 E, E; F if (yDir == "down") {
6 ?/ C* t- M# U. }8 [ if (yPos > (yMax - contentHeight - BallSpeed)) {: `' \" Z4 f* }$ O) l$ C* R& M
yDir = "up";3 A+ Z; V" H3 S' H
}
# u5 K7 c6 ]( C: i" [* s }
! M: e4 Q, W) r* [# ~& _1 U else if (yDir == "up") {, z: O% M$ B! d; X \ n
if (yPos < (0 + BallSpeed)) {$ g4 Y+ ?' F0 L8 O) |. V9 O$ C# \, A
yDir = "down";
# v4 A* ?4 d' k# e$ ?8 `- c% L l$ Q }7 b$ Z$ ] D9 v9 M" }$ ^* x2 g" A+ d
} K# V! G3 ^- ~% Y7 E) j& a
if (xDir == "right") {
- Y3 @3 f: T+ @- {, u xPos = xPos + BallSpeed;4 D3 U/ q$ y; @3 w) X; F7 ]7 w
}
5 f6 I: [: ~0 o- i% d else if (xDir == "left") {. Z& _3 T1 o9 [/ _4 c( b$ Y& G0 B9 I
xPos = xPos - BallSpeed;/ n5 v5 n$ S7 g& P2 T6 q
}( c7 \6 t" f5 p. _1 p/ q
else {6 I; O6 |. i* `$ ]1 ^! S0 F" P
xPos = xPos;
; }, c3 s& ]+ V3 f1 z' y1 ~ }* ~ H/ ~' b( D- }: Z, j; E
if (yDir == "down") {
, ~8 M% R) I; X6 a, Q* m1 \( a yPos = yPos + BallSpeed;
: d" {2 d2 c, ?" F! d }
$ y1 z: s# S& _" d$ k else if (yDir == "up") {+ M5 `& c' w3 D- _" }" C/ |* f. w7 {
yPos = yPos - BallSpeed;
3 m3 i3 w; X6 [( d6 E1 S: E4 G: q }
5 ~' S1 P1 d1 y3 ?4 ?. i E' H# K! N else {
- F [& T1 u. P. a! Y( @ yPos = yPos;9 p% s( Z2 i D& ~) Y5 P1 g
}
9 I5 a8 J; L% r }
; q' ~2 x( S! m+ c3 U; b3 _$ C3 Y; E* T4 h! {. C3 E$ J
function hidetext(){
6 M, V2 O* B8 J, J" `4 t1 j' u) Aif (document.all) O4 b2 j9 A& Z0 m0 Y, O
supertext.style.visibility="hidden"6 P# ~. ~& \4 C3 h* a- d2 b* D6 G
else if (document.layers)! p: {7 H% j4 ^) J: v
document.supertext.visibility="hide"1 `+ u4 M6 y. D v7 b v8 R. b
clearTimeout(animatetext)
: P, H; A+ L/ m' L# Q- _5 `}7 l; t9 H- ^8 L
' e* w( B7 j3 Y0 h5 m0 D
if (document.all||document.layers){ B) x( G6 [4 p3 {5 R" x
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
/ {% W+ S" I; w, Q1 c+ twindow.onload = initializeBall;. R" }: b r, @
window.onresize = new Function("window.location.reload()");9 g& u; H, n- b% q; g$ ~) C
}
( e* j2 z+ y* d' H% f! Z1 d, R& k+ a* r* m6 o$ e5 _( m |
</script> |
|