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

|
网页之不断弹射的文字-特效
<style type="text/css">
_& I3 K5 q3 i: M#supertext {4 n- M! B" i) D/ M4 n# L$ `
position:absolute;! y/ m; p! o' p! |, h0 f/ w6 T
left:0;
, |3 ?6 ` @* m. @6 g0 S) m) ~! btop:0;( m S0 X* N8 _* _( D6 o$ q
visibility:hide;
8 t# S% U' K# i4 F0 [* J( o0 T) c( c# mvisibility:hidden;
$ y t' u4 Y# b- [; q/ |+ b3 I. [$ q}6 e# R2 C4 n2 A1 N1 }
</style>. |) z2 Y! _2 d7 b7 U7 @5 a+ e: r
<script language="JavaScript1.2">
" w6 p x* X0 y2 D0 E b# ]<!-- 改变下的字体的大小。颜色-->
, b# C* A$ v* M( W# Yvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'1 N! I- i# k. }/ o
var hidetimer='';
. J; {2 Q8 Q' _& l% z% `<!-- 改变下的弹跳速度-->
. O4 b5 n8 y1 |9 V/ K( F8 {var BallSpeed = 20;
# }/ c6 T; T0 p& Lvar contentWidth;0 w% z: `8 o8 S4 K# z: m& X) f
var contentHeight;( d, M2 Q. L' p, n' c3 d) D
var maxBallSpeed = 50;
: T" H' f( Y, n- G8 k3 i1 {3 [
4 y- l" H* P3 I9 g1 _1 t0 n. L l) B5 W' J
var xMax;, I3 r0 n( }% E) V ?! c. P7 h
var yMax;8 w$ V+ X- U% C( Q
var xPos = 0;. t& w# F+ b! u. U. m$ B: e
var yPos = 0;9 j# l$ m# h' m) p
var xDir = 'right';
% F2 V" \' ^% E% x, W; v' r# @var yDir = 'down'; n1 d6 Z; U3 ^- w3 y" U0 R7 r& T$ L
var superballRunning = true;/ y# h: R% @1 u# F
var tempBallSpeed;
/ Z+ ?. c3 L' `. {9 T4 a' yvar currentBallSrc;! Q2 D5 k, v) F1 s) m* y2 g" a" S
var newXDir;
# Z1 c, w3 @" Q, o% X; l& Fvar newYDir;
) W/ |5 s1 l A% g! ~ W/ u! L
1 `, {$ v6 Q1 I$ p1 pfunction initializeBall() {0 P5 _- T; O* t% {
if (document.all) {- i* x) u9 o9 U8 v8 [) ~8 U q' Y
xMax = document.body.clientWidth
5 r$ }' T9 o) t1 @ yMax = document.body.clientHeight
% j. F( [2 |$ g/ ]4 v' W# Y2 y document.all("supertext").style.visibility = "visible";
9 b" N+ l! ~; _ Q8 w# T7 v3 S contentWidth=supertext.offsetWidth
2 o1 b( z7 f' l7 ^ contentHeight=supertext.offsetHeight
2 q$ b- F5 D( C8 ~7 s8 f/ n }, K6 w& o B: h0 o2 `3 K# i
else if (document.layers) {
8 G, A( J& j% g; V; d+ ~+ l xMax = window.innerWidth;' f2 p! H$ z [# L
yMax = window.innerHeight;+ Y2 Q0 s( z# X, K- i& n# |
contentWidth=document.supertext.document.width
' k, Z5 i+ O1 a contentHeight=document.supertext.document.height
' `* h6 p/ m* u B4 y! t! z document.layers["supertext"].visibility = "show";
' q. K. o- M6 u, X }) t! i! A% g/ s
setTimeout('moveBall()',400);
% V9 G+ m$ ?4 I$ J1 w. @/ B2 A" U if (hidetimer!='')) `) X& N0 O$ f* \( ~) X
setTimeout("hidetext()",hidetimer). m7 Q- S: l3 U2 ]. `
}' m- J5 Y8 _! j! Y+ x2 O
! O4 G# ~. E: G! u
function moveBall() {
5 |" @% Q+ ?* Z' H3 k4 T if (superballRunning == true) {
& K/ O. P7 h0 T6 o# W( D calculatePosition();
. Q& f6 [3 a; I. m/ f+ Q# y3 g if (document.all) {& Y( ~4 K8 j9 d: p! D- \
document.all("supertext").style.left = xPos + document.body.scrollLeft;, d% t1 q+ y2 u; Y2 r& K
document.all("supertext").style.top = yPos + document.body.scrollTop;8 U$ C" [) ^0 u/ O: w( F% }3 i
}
8 z; G- i. b' P Q else if (document.layers) {
& Y; x( @+ _6 g5 G) F* a document.layers["supertext"].left = xPos + pageXOffset;8 v! u) K9 m' ^
document.layers["supertext"].top = yPos + pageYOffset;9 w/ d0 V- j& L1 R- W
}
% Y8 K: V) M- a& p) N animatetext=setTimeout('moveBall()',20);( D3 d) z' F+ u/ n. ]4 k8 }
}
; N! a: ?4 n% m }
5 j' M, u7 F: ~* G0 E) G0 d ^. x/ b5 @( V: C! T$ X% m* \
function calculatePosition() {
, j5 t1 Q& _- V, J4 n$ z% k if (xDir == "right") {
% R- x7 M* ~3 c" N( J if (xPos > (xMax - contentWidth - BallSpeed)) {
$ H h7 I# ?$ i1 J' Z xDir = "left";
$ T4 I7 r C1 ]$ H }
3 `% w; ~1 X. K {! I; Q2 T } S9 `7 t ?( i% a o& k; x
else if (xDir == "left") {* `5 B1 E5 X& x* y' A- i$ _* G
if (xPos < (0 + BallSpeed)) {* K& Y* } i( y4 Z
xDir = "right";
: t% P( J5 L8 ]2 `3 |& ` }
# l; `' a3 F1 G }7 |$ b( r# H0 v
if (yDir == "down") {& w8 E! v6 l K# J4 L
if (yPos > (yMax - contentHeight - BallSpeed)) {
2 J% p$ J" A$ c9 l yDir = "up";
: f- S v* y+ }+ n" A+ H }
% B4 n3 ]6 n+ p7 ]9 Y( S }
( K& @ T6 N4 |. z else if (yDir == "up") {
3 d- a8 T2 O# e; j8 U if (yPos < (0 + BallSpeed)) {
+ O" {9 p" |6 Q4 K) |- n& W yDir = "down";
- } u1 P7 A `0 W& Z }
9 I% p) ?2 h2 Y2 q8 N h4 V# o }
3 q: \8 g& c [% ~ if (xDir == "right") {. }1 j7 g) p/ @9 B6 Y
xPos = xPos + BallSpeed;
9 z; ? ^$ U: p/ ]7 k$ }+ z+ I }
1 y2 C9 n- E, y% h8 z) ]5 _# ` else if (xDir == "left") {. S& W( {- |( a/ ^
xPos = xPos - BallSpeed;% A+ X0 K- S, l+ g
}
# l5 x. n2 S( {) P2 m7 s else {
9 ]7 U5 X/ y- S- ~ xPos = xPos;
, _- A! f! b1 {$ H4 L }8 q; B7 N, s; U' Q8 O4 I' x' N: [
if (yDir == "down") {$ _: f F0 V8 {# m" n
yPos = yPos + BallSpeed;# I! c" V( l. k, H7 V
}/ `: g, U4 x+ q. ~9 L9 ]/ ]
else if (yDir == "up") {
; i: c4 D% k: x% O) O8 [/ ^, h yPos = yPos - BallSpeed;5 {3 W, \9 E, Y- z
}
6 J! `( \- w8 R/ A; ~ a+ K else {
1 o# {8 a( p; G5 T" [1 |' E2 v yPos = yPos;
F. g( O' v `: P7 b }6 b3 u" `. U2 y) c5 {, u( R
}- [& |: d, A& ?8 Z" O
. G) c# y4 i+ W9 I/ d3 ?
function hidetext(){$ _8 |8 @+ [8 b; x; c3 Q
if (document.all)
- q- {3 P6 _6 h- M& lsupertext.style.visibility="hidden"! A0 Q7 _8 E% R8 m6 k% B4 m( R
else if (document.layers)
: Y" j1 p0 x H, Qdocument.supertext.visibility="hide"
" K3 f8 i9 |) Z% D; t$ HclearTimeout(animatetext)6 Y: }3 V% o( v. r) X
}
& l( u9 f; |0 G
3 K8 E- k& y& Y _5 k0 Zif (document.all||document.layers){
6 B# K) ]0 t5 X! |2 T* O" cdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')1 a0 z1 Y2 p# X/ o$ a( K' w
window.onload = initializeBall;
( K H' g4 U% ?' z( m i3 Pwindow.onresize = new Function("window.location.reload()");- t. j3 F4 J8 L! {8 C- z
}, l4 k4 I( e. P$ N7 G# n
5 j1 R/ [1 ?* S: O& ^</script> |
|