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

|
网页之不断弹射的文字-特效
<style type="text/css">
$ s2 ^% M( c2 D- d8 L- I. j! P* F#supertext {7 Y E/ G- S+ s Z
position:absolute;
4 U4 G. z: T' \: @! o! R. S; [left:0;
" J2 g$ s& I3 x$ d# \% K1 jtop:0;
* i, C _' L* ]visibility:hide;
& Y$ y* V. }- @" H4 Jvisibility:hidden;* |" R2 G/ C* L, s- V
}
- J; G* h! w5 K. w4 L/ N</style>$ K4 g$ D k$ ]" F1 o3 y( V, }
<script language="JavaScript1.2">
( W3 ]7 [4 E! G- ]# d6 G" i6 Q# ^/ G# b<!-- 改变下的字体的大小。颜色-->8 {; T s' S! n$ @4 t, s; [
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'2 G$ W8 y0 q) l) A# U ]" y
var hidetimer='';- R" t, F' L# o9 v, v- q
<!-- 改变下的弹跳速度-->
, r# E$ Y9 x) R3 `: G$ Hvar BallSpeed = 20;
/ x3 b. p; ~6 z2 `1 l) {% J9 Zvar contentWidth;
) k/ r) C5 b( C* pvar contentHeight;
7 Z0 V2 ]: x H* yvar maxBallSpeed = 50;
2 B6 J9 e9 {3 W+ P" {1 H* j) t: Q4 ^4 V
: x u0 ?7 t* n4 K0 \/ N3 J" V9 U
var xMax;) ?, J W1 S1 f2 S% i$ o
var yMax;, T- ?8 {! V- H0 c5 J4 q
var xPos = 0;
+ B& ]7 O) @% k0 x. {5 kvar yPos = 0;
% v& w C3 a: W+ lvar xDir = 'right';- Q3 ^- |0 @) [9 ?
var yDir = 'down';
5 l+ V7 x: x# Z# [, I; d5 [var superballRunning = true;3 h2 d( b; I2 ]3 b
var tempBallSpeed;, B: D+ s" e- N, Q! S
var currentBallSrc;9 U+ l) x$ i( J- |( u
var newXDir;6 W# Z+ o$ ]6 M$ E+ i3 Z5 @! p$ ^
var newYDir;2 g; F2 o# }8 X
( J7 z0 ?! k, \/ Q! L& ifunction initializeBall() {
% F7 @" f3 {. }+ i$ h% ^ if (document.all) {: ? ^1 v8 ]) U2 I
xMax = document.body.clientWidth
# ~5 ?' o8 Y& Q yMax = document.body.clientHeight
2 n7 S' A1 _! b document.all("supertext").style.visibility = "visible";8 u* d$ y; g* v( _# ?' G
contentWidth=supertext.offsetWidth
, f$ a) e; P a4 n4 g% F contentHeight=supertext.offsetHeight5 U5 I4 M' |! p1 W
}
i) Z- r: H! z) B4 f else if (document.layers) {9 \, D/ i9 C( O* S
xMax = window.innerWidth;
3 l& z8 j! K. t* G# A# X yMax = window.innerHeight;
2 @+ V2 [0 ~/ ^5 \& I contentWidth=document.supertext.document.width
& q5 X9 }: t' D) ~ contentHeight=document.supertext.document.height
q% q* S" o! r' c- u document.layers["supertext"].visibility = "show";4 n3 a n1 q/ u9 [4 [) t
}
/ g9 k" P3 q( S' g/ m. N9 H setTimeout('moveBall()',400);
/ S5 @( j K+ Q2 t& C if (hidetimer!='')! Z9 u! g( q, B7 a) \( u
setTimeout("hidetext()",hidetimer)
1 U6 X' P6 m. Q8 Q# R% W }! C9 s5 t* m; z( @
4 u$ G/ M$ f% {6 N* y$ s$ F# u
function moveBall() {1 \. S4 r6 X7 ?) V. \
if (superballRunning == true) {4 |9 O* l) ~4 n* Z( k: w3 g
calculatePosition();. c3 c& u, }2 O! |* O0 h
if (document.all) {
( I; n: D1 P; J' D! ~$ ^ document.all("supertext").style.left = xPos + document.body.scrollLeft;# H( \6 f+ v: A/ ]2 ` r& O+ Z
document.all("supertext").style.top = yPos + document.body.scrollTop;
" K) ]7 c1 w! B }7 N& W1 B T. a' U- X7 b1 |% h
else if (document.layers) {: M; P# i A( D5 J3 J2 Y2 J
document.layers["supertext"].left = xPos + pageXOffset;
1 S- _& P# ]4 E. l document.layers["supertext"].top = yPos + pageYOffset;
& a% f* r! R% c }
- D; V) n, n! }# H+ G( X5 Q animatetext=setTimeout('moveBall()',20);
5 B1 l; h. Q2 X }
. g# i) i8 v5 _/ H% E }/ Q# n2 M1 p2 L$ U: F" ] O% q
1 d6 p, O4 I8 X4 k- H
function calculatePosition() {: M3 \. n: i& A/ [3 \- c( `8 a
if (xDir == "right") {
9 P0 ]3 ^+ E, A* w if (xPos > (xMax - contentWidth - BallSpeed)) {
: z9 j6 M! B* w- h1 V! P xDir = "left";
1 F; n& T( y8 F" O L; c8 S0 Y2 z; Z }+ k" }5 l( V: \, i
}
: g! u/ J; [ n* a' ] else if (xDir == "left") {
9 m Y3 Z+ _' z1 j if (xPos < (0 + BallSpeed)) {
3 n+ M3 f- n% @% ^9 M, h; g, l xDir = "right";
1 p4 m) N7 l* k }% l0 g3 A& L( G6 j4 Q8 K: j6 H' Q( E
}
% J+ P( [+ X9 i5 n) l# m if (yDir == "down") {" Y7 T; _3 K$ Q. v* I- K( j" t
if (yPos > (yMax - contentHeight - BallSpeed)) {
( @: M; L/ Z! c5 r% U+ c yDir = "up";- k% Y& J3 Z) T- ~9 B \! P
}
! ^% e( g9 P# ^ }' R1 W: F: W0 F- n/ G s
else if (yDir == "up") {7 t7 t9 a$ o# f! ~) D- N/ `
if (yPos < (0 + BallSpeed)) {
- a4 j+ d& `4 P5 S* H yDir = "down";& b4 I) J# T5 [- m- X
}# N# j L g9 t, v' J! c7 @, ]
}
; W# H+ F' S+ [; x if (xDir == "right") {
: X$ Q: ~$ N3 @# j* ], G! }+ f" M xPos = xPos + BallSpeed;
2 I/ }& f% A; G }
@! e% g2 K F" F$ b5 f! V else if (xDir == "left") {' K. v4 u- h. K( u
xPos = xPos - BallSpeed;
( }0 Z' ^8 D7 k$ N }( S1 i& M0 {$ b1 o
else {$ l( t1 X6 t2 E" H" G8 C1 u4 l
xPos = xPos;7 j. C& V7 ~( b/ H( o- P
}
D3 L- ?6 d- ~4 ]$ C# B if (yDir == "down") {
9 r% @6 ?0 ` g4 z/ _5 y/ p yPos = yPos + BallSpeed;
3 L0 P- r. f7 Z' I. k }6 R7 Q/ s/ D! \$ J; {! L$ X
else if (yDir == "up") {
. k. g. K S( s6 A d+ t* z yPos = yPos - BallSpeed;2 D J w- n- G
}
: Q: \) T. V/ Q) }2 @6 _ else {
$ R' C0 G @6 Q8 _- P yPos = yPos;4 J8 p1 |- M$ w
}
* Z" F; R3 i: j7 ~) Y }
* j, i) `1 t4 [" A5 x6 }
/ W9 T \1 r. [% s5 bfunction hidetext(){
9 Z' h) W8 a$ J9 dif (document.all)
0 v5 j e( d- m/ L. l& D/ ]supertext.style.visibility="hidden"
1 d4 \. z) h& p0 Celse if (document.layers)0 n9 @8 x( q2 O- c' g2 c
document.supertext.visibility="hide"$ G$ Z2 B6 o, h
clearTimeout(animatetext)+ ?4 x: v4 d. t* b m7 u2 P/ o( \
}. K+ O! C3 h: e1 w8 r; R, P' t9 @' L
0 i6 P" ?2 ?1 N' Jif (document.all||document.layers){/ E* c/ r7 f1 T: N1 I) }
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')" X& U7 {$ w) i
window.onload = initializeBall;
4 i: K8 f# ~: M, [' _4 ~ Kwindow.onresize = new Function("window.location.reload()");
, ]& e7 X' e% V8 M ^- {4 B; u5 \; U}
+ N9 `4 D! }4 u/ V$ H
) Y; e& t+ g0 B1 E: u</script> |
|