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

|
网页之不断弹射的文字-特效
<style type="text/css">
) A% x# a2 E7 ]: R- s# R5 N#supertext {
' \" `: b# Y6 Aposition:absolute;
% g9 i' O+ B4 l$ p0 ^left:0;; F- r7 z; \; p2 p0 g# B6 A# A- b' r
top:0;
) U V ^( S3 ]visibility:hide;
# I3 m v2 H0 _! O [# M6 {# j* Avisibility:hidden;- B$ y# }8 q% H; A. V) J
}$ L9 V7 s9 z5 w( R
</style>5 U# ~/ \4 Y' l4 z
<script language="JavaScript1.2">
9 ~8 l4 [% S7 A9 I<!-- 改变下的字体的大小。颜色-->
: g+ Z& v" {# i1 a6 Pvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'4 f& G; n' Z7 o8 }4 q! p
var hidetimer='';: w( `8 d2 M% N9 A1 ^3 u: ^8 M- u
<!-- 改变下的弹跳速度-->
' P* T5 O1 X" g5 j- Gvar BallSpeed = 20;7 F; E5 m6 x: s( r4 _
var contentWidth;
; {8 |. x' J" v1 k9 M" A/ _8 W, Evar contentHeight;
; q+ G: B8 B" u; Y! p: lvar maxBallSpeed = 50;
: J0 `* x) N' X N |* @/ ^$ m/ U9 W/ P( z7 d4 L2 v
: l2 W* E5 c& x' G/ L' v3 R" xvar xMax;
8 a' ^" K( |+ G. J) @- e- Z8 c$ Bvar yMax;
4 r* I& h" m% { I2 Lvar xPos = 0;0 H7 x2 F. ]$ R9 I- ?! D
var yPos = 0;
" X% R; x5 R; x3 x' `+ |+ b, u4 A) \var xDir = 'right';
) c) k0 f- i+ cvar yDir = 'down';! r3 ]6 Q# ^7 E
var superballRunning = true;1 N6 f' I, C+ H/ n1 [
var tempBallSpeed;: r2 A9 k% n/ J5 Y+ m
var currentBallSrc;9 O" g2 d% x# x4 y
var newXDir;) b9 Q! ]: J& M1 T: H0 r( ]
var newYDir;
+ L1 _) [+ ~; H6 O) ~% R6 C4 w9 ~
1 Q2 n* U1 A: E/ V( t+ G9 G$ ffunction initializeBall() {5 ~$ R5 H: r; L, A& Q" r
if (document.all) {
; i# a- [7 _% e# o xMax = document.body.clientWidth* y" g3 y3 n- n# |4 i: g
yMax = document.body.clientHeight
$ \9 x) a! J- R& Y document.all("supertext").style.visibility = "visible";% p4 G P8 B, a" O" z
contentWidth=supertext.offsetWidth" d! D F% ^" |" x. Z% K
contentHeight=supertext.offsetHeight; a4 ~& [* \5 B$ H- M( P6 q/ d5 d1 m
}" F& [! P9 r" r! P `0 t2 J
else if (document.layers) {8 }1 J! ~, _, j; P/ `; T# @8 \
xMax = window.innerWidth;$ h( f( T9 B- t0 R4 P6 |" z* r) ?
yMax = window.innerHeight;
4 H. {& c; u8 {- t# G& @6 N: S contentWidth=document.supertext.document.width' c* U, c2 T2 Z/ X
contentHeight=document.supertext.document.height
& y, @: |# V/ w9 m7 G- t document.layers["supertext"].visibility = "show";
/ k: N# I R$ E) a9 K2 K8 z }) w& t9 z0 z, V4 w! D+ x
setTimeout('moveBall()',400);
/ U1 |& a# G0 L, ~ if (hidetimer!='')
4 h* c8 e! C3 c setTimeout("hidetext()",hidetimer)
* L3 n& _9 N5 H$ `6 O: h6 `; L }, T8 ^, i+ ^, `7 i, h. A* v$ }
8 C: N( z7 g9 G L( \
function moveBall() {( G! Q d. X" B' e. R0 |1 C
if (superballRunning == true) {8 L1 L2 q$ N2 u5 k
calculatePosition();" v! N5 ]! C8 k* _6 `) o
if (document.all) {
5 u( [' |& R1 ]$ N" r1 S document.all("supertext").style.left = xPos + document.body.scrollLeft;: \ w# ^* A% Z% {
document.all("supertext").style.top = yPos + document.body.scrollTop; S1 j7 v4 n: X1 w1 F" d
}
, y/ K5 x+ U* w: K2 K" m. i- _3 T# N else if (document.layers) {
0 @6 V4 |: l6 K3 G& @ document.layers["supertext"].left = xPos + pageXOffset;
2 L$ `8 P: `" K! h document.layers["supertext"].top = yPos + pageYOffset;
- n) ~4 U8 ?# J, Q4 w( M7 q }
/ K* J/ n; A! L* T" O8 v2 p' p animatetext=setTimeout('moveBall()',20);
: H8 G( a: l/ x y$ v! G& G) C }' x9 ^1 z; U3 `8 m) y
}
8 R" j6 {4 N% J2 N% L. E8 |* G
5 P+ ]% d: C6 d1 L2 q) X; ?function calculatePosition() {' K c# h3 r: b, S
if (xDir == "right") {
/ n7 K. A# S+ n: p, k& { if (xPos > (xMax - contentWidth - BallSpeed)) {9 b3 ]% x* {" U, `! l
xDir = "left";
/ l* h9 P7 [6 B" N1 _1 H l }$ ]) P0 k: E7 X, X
}7 ^( z# R8 L: v, T+ N1 L/ U
else if (xDir == "left") {9 k/ `- ^ @- O
if (xPos < (0 + BallSpeed)) {
6 I" i9 [0 Y3 L# o' k$ ` xDir = "right";
# _4 |9 O6 h! C7 `" I: H2 n }
( E8 |6 m$ c* x }9 q! X* w6 u& s
if (yDir == "down") { \* }& k( z3 N
if (yPos > (yMax - contentHeight - BallSpeed)) {
$ f& z2 i: M0 n& W% C8 R9 J yDir = "up";( G5 X3 N7 n& w: A
}8 P; l) d2 @9 n* @
}. }: c. E# Z& A7 z: W! u+ y
else if (yDir == "up") {
* p& ^& @9 S. V7 ?% T if (yPos < (0 + BallSpeed)) {
* C" K5 U/ Q; x3 ]. X yDir = "down";
. N* t& x( o1 r! ` }- [3 z8 D0 G2 t. J" ^
}
5 d$ v" w: a' Y# R/ l* o7 b if (xDir == "right") {1 S5 J* S5 b' T! F
xPos = xPos + BallSpeed;# A" p; f g2 n) Y- D$ x. j6 h
}1 ~2 ^" Y# C$ _. C g
else if (xDir == "left") {4 X* t4 |# C+ P. F
xPos = xPos - BallSpeed;
' {: w5 E& {8 P% `, c }
. U& O. z! i! ?. B7 x4 W else {) y$ K! p- d/ T9 M+ K
xPos = xPos;& J) w( A" w7 V* u! ]
}* { _# i, k6 Q& N+ T, B
if (yDir == "down") { _% O5 d3 A W* U, y) `) `, `
yPos = yPos + BallSpeed;4 c2 p9 r4 n+ R0 y" w
}8 i2 p" Q. i* C8 d
else if (yDir == "up") {0 v& C4 F! Y& L/ E$ R
yPos = yPos - BallSpeed;
* j: R1 _; w# u; b- p8 q3 P }; `0 @/ J0 ^+ f- _
else {) B' A- k: K/ U: P1 }! t
yPos = yPos;1 u6 {( \: s7 l. V+ o6 E( ~
}
4 a0 m# T9 F% C3 ?' G+ v7 A }. C$ {7 V s- L0 u: Z; A' _
5 T& e- t: j3 Mfunction hidetext(){
$ L; D* k. T9 s& o/ b7 ]9 y: yif (document.all)% [5 t$ Z! x R4 G: x% A7 h; v9 |
supertext.style.visibility="hidden"
- e$ ?* c, [8 o. B1 d( O# Eelse if (document.layers)( M& m0 H; R" y! ^$ r* O' x, k' Z
document.supertext.visibility="hide"4 s7 o+ u4 ^% r+ A
clearTimeout(animatetext)
6 G" Q9 O: C) b7 _}
4 b' i1 f. U1 _) l; W+ w/ Z! P A1 [# b; l) a9 S; Y3 ]4 B; J3 H
if (document.all||document.layers){
/ m6 Q K. x$ ^4 T# tdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')' D8 |8 P1 S9 [0 M% R7 B9 ~ K3 Y% A
window.onload = initializeBall;% s8 C0 g. L# Z: x' h' N
window.onresize = new Function("window.location.reload()");( W1 v1 S. U% q! [7 E# x
}
; a5 D- a1 y. z, @5 |) g' u- o" A, \1 q' a+ j
</script> |
|