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

|
网页之不断弹射的文字-特效
<style type="text/css">
4 A6 Z! _4 c# f( A, q8 L. g& X# v#supertext {) B- V" e- i1 g9 b, c6 w
position:absolute;
N$ n' {) B1 f/ h8 bleft:0;+ V% a: Z0 ~- p
top:0;. X) E* n( R0 P" |
visibility:hide;
, Q7 e- H& h1 Wvisibility:hidden;
2 g6 m1 T& C" L1 {1 `}2 `% q" ^% X9 ?- S& h
</style>
{- [3 j% E# R4 X H E& m<script language="JavaScript1.2">
5 I2 b+ H+ m6 {7 s<!-- 改变下的字体的大小。颜色-->
]: q' l. ?7 ]& J1 X! ]var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'# h" Q! S/ ?3 y% `7 Z7 `
var hidetimer='';
- } [2 u+ i; r$ p; e# V<!-- 改变下的弹跳速度-->
9 l7 y, M8 ^. f, b& S5 E0 C# p0 ^, xvar BallSpeed = 20;
) _) r: B: `. U& T' avar contentWidth;
2 T, ]! b5 M: d" s- _) v8 \' Yvar contentHeight;! s: }* t" }! W8 g' e, k4 P- j
var maxBallSpeed = 50;
! [' b- F/ x! |& Z+ o ^& g) O( D; k) Y; |0 H- j9 P
& U4 y ?8 q( ^/ m1 T+ U
var xMax;) D6 P& o8 n2 j7 e' s
var yMax;
; Q% i) |! e9 ]) r' Kvar xPos = 0;" ~9 X& \5 |4 D @ a
var yPos = 0;
, W; q" a# c b5 Ivar xDir = 'right';; Q3 }* y; V+ ?. n& p
var yDir = 'down';
- K1 G" h+ b5 c1 n' o5 M# Rvar superballRunning = true;
4 d" g4 h; `9 z. ~% T% i# \var tempBallSpeed;+ \( Z9 P2 G0 H/ K& O _5 {; W
var currentBallSrc;+ @5 G, [( Q7 ]+ |. H% G# y" Z
var newXDir;! r/ \# j& f0 Y X! D2 B
var newYDir;
5 s! R# V4 W4 s' M# N# p
; u6 j- l; M m% {# r: u- kfunction initializeBall() {
% C. F, U' s+ \9 ]/ l1 V if (document.all) {
6 e5 v- S% e# \8 O# | x& \. J xMax = document.body.clientWidth8 G: L, ]3 @9 c$ \& H
yMax = document.body.clientHeight
3 a- G3 z) T5 a4 Q% O% ~ document.all("supertext").style.visibility = "visible";
( D( x% P; B q8 b" n# k contentWidth=supertext.offsetWidth7 K$ z# Y) E! P7 w
contentHeight=supertext.offsetHeight) W/ y C+ ]6 `% O* R7 j
}
& L. f! {3 ?+ b Y0 @ else if (document.layers) {, ^. _( O% u8 d5 p1 d
xMax = window.innerWidth;7 j7 B) x, ]: |7 ?0 R
yMax = window.innerHeight;+ j$ n) _; Q) t" D3 \! y# `/ e
contentWidth=document.supertext.document.width; b7 h' M, X( R1 T
contentHeight=document.supertext.document.height
0 O6 k% B: D# i document.layers["supertext"].visibility = "show";; `$ u9 P% g+ \3 B6 T3 f
}# D' K1 o5 o( q' `4 F k" b( _
setTimeout('moveBall()',400);
* \' c8 v3 S$ S# @ if (hidetimer!='')
( v, }# b( U! D' b8 R1 U& z setTimeout("hidetext()",hidetimer)
4 W& \. ~3 i; r }
% v6 W. b" t, a, ? U1 w: M
/ v7 u; g A( w/ O1 \# |; y5 J; |' Cfunction moveBall() {: d- m6 ~5 U1 m: T/ i
if (superballRunning == true) {
! h" ]5 z% ^4 S) ?1 w calculatePosition();
# m) s! G) K. W: a if (document.all) {
% G% P& R; o3 y7 b7 i document.all("supertext").style.left = xPos + document.body.scrollLeft;
) w( l0 Y! x. R2 m3 ^7 t+ Y document.all("supertext").style.top = yPos + document.body.scrollTop;4 }9 y$ m' n+ B ]" g3 ^0 x: j$ c
}+ @7 n+ v4 u" L( w( i9 v& k0 m. x
else if (document.layers) {
! {+ C, w3 T6 M" ^! y! b; b document.layers["supertext"].left = xPos + pageXOffset;
* B4 i: M7 g3 c! S document.layers["supertext"].top = yPos + pageYOffset;6 o: W% u7 ~5 ?0 R; |
}/ K" |/ O+ ]: C t" v$ u
animatetext=setTimeout('moveBall()',20);
. I$ Q* O+ s# p0 F1 H }) p. G# j7 o3 ?7 w5 e8 s
}
) X) i, N4 i5 V+ F8 h. Q+ y- F6 n& b4 r+ z
function calculatePosition() {* E5 p4 i( \2 \+ w8 r$ R& K/ [- f
if (xDir == "right") {
4 O1 B1 o1 P: x" j$ h/ t& @5 C if (xPos > (xMax - contentWidth - BallSpeed)) {0 l9 ^6 v8 M, t' y
xDir = "left";# E! P; T% k. q {
}
* O3 }3 x5 s d+ B5 t8 q- M }* g& t+ R) v4 Q. Z' u
else if (xDir == "left") {7 P8 Z! ~' X, x& g9 N8 C [
if (xPos < (0 + BallSpeed)) {) v7 ^, ^+ P; h
xDir = "right";5 G' M, M$ ?, Q2 }
}2 e7 R! z& N7 h4 ~7 y' M: p( o' G
}4 D" ~7 u; _, B5 O% q
if (yDir == "down") { ~5 }/ N; R" I; @: R9 m* _
if (yPos > (yMax - contentHeight - BallSpeed)) {, T# a. x; b8 i
yDir = "up";
2 n" G7 i3 d% k+ T+ v }
0 g6 X/ Q7 l) M& M4 g, Q }4 m) C& `* ^! r! Z$ \
else if (yDir == "up") {) F$ b, ?3 Y8 M2 l2 O) M
if (yPos < (0 + BallSpeed)) {! ^6 F$ [1 ~+ S7 T* H9 l7 u( `
yDir = "down";
9 @0 y3 C1 C' B5 } }: d! b2 B% d X8 P
}' G- w' e9 B2 y4 _" W! ^7 F3 }
if (xDir == "right") {$ R! m# J* J) I( o
xPos = xPos + BallSpeed;+ l' W" x, }- V4 k% l. U" U* J
}
# ?# V4 |' B& u L* ^$ N# N else if (xDir == "left") {: ^6 P: f; k% [5 K
xPos = xPos - BallSpeed;, h; j1 p' m3 M7 U7 O
}
0 t6 O& F |( K$ J else {
7 ` O0 [$ Q- t* o2 s, f' u xPos = xPos;" B! b& M" y7 H
}( n1 ~* _' H8 B
if (yDir == "down") {
5 F+ A2 C2 |2 Q7 P yPos = yPos + BallSpeed;+ v# R" ^! v* D5 h6 {1 Z* N
}
6 _/ z2 r7 |$ P9 s else if (yDir == "up") {
( k1 f- t+ g3 L% D& _ yPos = yPos - BallSpeed;
& R% @- q) _6 L6 J$ R2 U1 J( ` }! d, q3 k. r( ?9 d# a9 V/ |$ Y( M" V
else {2 ~' X4 ?4 Y6 o# Z" o
yPos = yPos;
! S, B) g0 `. U3 ], a }
R" n/ d- y" i8 z$ P3 P% K }
( M& z3 ~) d1 N6 z8 {; V
% k8 f. G0 z2 n% W6 Qfunction hidetext(){
# t8 Y! L# G' |$ y7 v+ Fif (document.all)
5 A! O3 t. T" _- N3 N/ Fsupertext.style.visibility="hidden"
4 V+ [7 G* H) |+ a n0 Belse if (document.layers) K, T" g' E# t. X
document.supertext.visibility="hide"
( V6 k4 c! E. j! S2 OclearTimeout(animatetext)5 X E- t3 [4 t% [2 N
}
& e3 a, M4 t( d- x. ~
( w( m8 O1 u, h& N" a% u6 dif (document.all||document.layers){+ a, C6 f2 c( _) r
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
& P6 J6 t" L; W" z) P8 y; k. Owindow.onload = initializeBall;
+ Y! o' c' \' H* ~window.onresize = new Function("window.location.reload()");
7 A& [+ X4 w0 U* x' J$ n, k, V}
! E4 \5 R1 I3 d- Y
. v7 K* q* I7 r; V7 O: b% ~: v1 ~</script> |
|