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

|
网页之不断弹射的文字-特效
<style type="text/css">" a( K0 j8 P- G* F
#supertext {
' L: ^; Q, Y: Z4 e& G* eposition:absolute;$ {: T* P& Z0 `0 q+ f. ~
left:0;
. j9 R: W" f. j2 N, A9 x$ Ltop:0;' p0 N8 n8 k) a& w# v
visibility:hide;
: L6 C- k7 i& C! [. O. Dvisibility:hidden;
8 i, @* `% k7 D5 v$ q& x}
7 @6 P! u# y# ^, O/ {% a</style>/ u4 C9 H! w. m6 z* x
<script language="JavaScript1.2">7 G4 u; Y! ?/ p, g- b4 v
<!-- 改变下的字体的大小。颜色-->) U6 S" A0 ]9 p+ t
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'% J: @5 x7 d9 V/ v' q; }/ y
var hidetimer='';0 a |- ?: X2 u, U3 Z% P
<!-- 改变下的弹跳速度-->
% {9 I/ W. s2 q) e& J' E0 cvar BallSpeed = 20;
8 d. h& `- X: E% ^( y' V8 @var contentWidth;
- W0 o& V3 q4 w6 z0 \var contentHeight;
4 W; h0 W8 p$ W& Pvar maxBallSpeed = 50;( f3 G, l% J1 A) s6 A% b
% M( p w$ T* G7 T0 A! A* ?
( T* p/ {* u0 ~" E1 u' ?var xMax;+ x) k' E6 d: Y" t# w1 ^1 U
var yMax;6 d( p6 w. b/ X4 P1 e
var xPos = 0;7 o' }6 t9 ]" T$ f! r( ?! \
var yPos = 0;- D; |- E M0 D3 p/ ?7 {
var xDir = 'right'; H X, D6 g4 t* i* `+ K4 h
var yDir = 'down';+ s) I, c0 R7 G- ?4 u/ i7 K1 i
var superballRunning = true;
: {6 [ l# j9 q5 d5 f' ovar tempBallSpeed;/ R: t* {' {; C7 j" e1 F0 ?! B+ e
var currentBallSrc;9 C5 g& Q4 H7 Z# _$ g4 s+ ?! x
var newXDir;8 e5 i+ `7 @7 F7 z: y8 i$ J
var newYDir;
" b- @! s* F. U# q( q
1 M* n0 t" J3 T# O/ z( r3 wfunction initializeBall() {
" R8 h/ \& G# }: Q( f7 R7 ` if (document.all) {
3 o8 E/ ^9 Z: U& ~ xMax = document.body.clientWidth; Y; p- [8 ?$ E- Q
yMax = document.body.clientHeight
3 u$ K- M( ~- E( Y$ u- s document.all("supertext").style.visibility = "visible";1 | `, j l5 d( A. w4 T) n
contentWidth=supertext.offsetWidth
, |( s' T; p7 n contentHeight=supertext.offsetHeight8 |$ I/ S* r! G8 ~; ]7 \* o3 h6 P
}
/ e# a2 Q/ `6 z8 O4 f, B else if (document.layers) {
7 D6 p" b" }+ Q+ w5 w6 o# r xMax = window.innerWidth;3 Y7 f. U% Q& e, F4 \
yMax = window.innerHeight;
/ H; G$ {+ h8 R! B: R contentWidth=document.supertext.document.width' m4 ]$ G Q5 R" c
contentHeight=document.supertext.document.height9 f- `* u2 q3 `" D- b c
document.layers["supertext"].visibility = "show";! z; l5 B3 p7 ~
}# B0 l" [+ j0 g; j5 M' Z# _
setTimeout('moveBall()',400);
, P% L2 t3 l6 J if (hidetimer!='')
& q: R0 ?! E; ^ setTimeout("hidetext()",hidetimer)9 n( `$ `, N. F3 L; y8 q
}
' [* Q1 Z2 N& L5 {# E2 u+ w
6 j* V8 f7 b6 e2 r# y' Xfunction moveBall() {( O: i$ j- W; |- c' o7 }* U
if (superballRunning == true) {" j3 A8 d$ ^/ q2 s; e
calculatePosition();) Y+ f+ ]2 N" G* a: a" K6 \0 @0 P
if (document.all) {
1 i) p8 r3 }1 b7 k- O3 G6 o$ F document.all("supertext").style.left = xPos + document.body.scrollLeft;
$ y8 P' \& n# F" E$ ^- X document.all("supertext").style.top = yPos + document.body.scrollTop;
1 v) B. L* s0 Q }; G1 Q/ x! o. c- v
else if (document.layers) {
9 J. l5 m) V7 [3 j2 B; ?9 _; q document.layers["supertext"].left = xPos + pageXOffset;- d/ i) J/ e" U- V5 [. R* O
document.layers["supertext"].top = yPos + pageYOffset;
$ y# a ?; o: w6 V. I }7 D+ l* l# C* i# T# a) o
animatetext=setTimeout('moveBall()',20);
$ r' c0 @* A9 I9 W; u1 F }
# f/ f9 V8 M; B; F3 e6 w }5 {0 y- d; c2 H
6 F* d# ~( ~( c, r5 P; I$ |, e
function calculatePosition() {
. r: d7 k P5 t% H# Y. P if (xDir == "right") {
4 q" {. J8 W) f. X if (xPos > (xMax - contentWidth - BallSpeed)) {
8 v" M- A( [ R z5 w, e2 z xDir = "left";# T. d) h. Z' F4 ?, K& `2 ?
}7 k' R& A# c2 j1 v; H* n5 w8 L
}/ D8 C4 Q$ `9 ^( X: L$ V
else if (xDir == "left") {
$ m5 m' d' [7 b4 N4 L+ {) h4 q( C if (xPos < (0 + BallSpeed)) {8 Y5 g8 _! `0 l4 A: V. |5 h
xDir = "right";
: r3 E2 H6 \' g# v8 f } f! L8 E1 w8 \, z! @; W& f
}
4 W9 k+ K' r+ x O+ o if (yDir == "down") {5 X& Z4 O( h) x1 C9 c, f
if (yPos > (yMax - contentHeight - BallSpeed)) {# ^* A4 n) x( V: [. ?2 m
yDir = "up";
8 _8 b& k, l. m- O$ D }
( i. L8 T/ V2 P }# D+ B+ T L7 B0 F8 ~
else if (yDir == "up") {
3 u# k, L: W$ d5 w: P5 Z: ^! x+ L if (yPos < (0 + BallSpeed)) {
, P# {# O( C" x7 O2 v6 q; i; j yDir = "down";/ E( H" a* {8 l
}* `3 k d) |' r2 n7 J3 q) q
}
, @9 p3 S& [/ t if (xDir == "right") {
A; j/ ~5 M0 i3 b xPos = xPos + BallSpeed;
* v! v1 `, e; v+ l! C, H2 e }3 a; G+ G$ S$ O, T
else if (xDir == "left") {
+ {8 k% m7 d j" x% G. p xPos = xPos - BallSpeed;; t9 j1 W/ w. T* d l/ \5 ]0 L
}
1 H6 }: l/ G' M$ Y2 d% k else {
2 H4 l/ ?3 a y8 I/ W' K, { xPos = xPos;
, z' S% y# X5 V7 T4 s7 {) ]. }4 x }0 n7 f6 T- l `6 _6 h/ e" o
if (yDir == "down") {# F7 h; g! d4 \- U* C+ b. b
yPos = yPos + BallSpeed;
0 G. k2 T& r5 k; f }' R* r0 ]2 w" u( i. Q
else if (yDir == "up") {
6 `$ m) }* Z9 B Z/ X f7 A/ | yPos = yPos - BallSpeed;
- f2 L4 U+ H& L+ P5 p }
3 e% T7 F/ p$ b2 k6 E& n9 Z else {1 ?, {: I) x* j) p) I. o
yPos = yPos;
! d$ q; W' Q, L. { }
) S; ? o* k: d! _! M* B3 p. {/ C }3 m1 J# W# w! n z" X4 q0 Z4 q
+ a& T/ J) ?0 F0 w" C/ z7 B
function hidetext(){
% V' X: y* a" T, h) O$ I( U: pif (document.all)
0 W: f9 |7 }- d! e% Y) Osupertext.style.visibility="hidden"
( H. k6 g6 W9 p/ yelse if (document.layers)
. N" h* i$ l% p5 G% f2 _document.supertext.visibility="hide"! n+ V4 m( A" V2 D0 i5 v! X
clearTimeout(animatetext)
3 N9 k4 v( V& ?- `}% K- x4 t$ P- }$ n
2 s" H- b+ S; h
if (document.all||document.layers){
8 r4 A9 p4 z. z% \) }5 w3 E0 ^! Fdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), V' F- W, o T& f
window.onload = initializeBall;; c" [6 N# P8 F6 {
window.onresize = new Function("window.location.reload()");* W, }+ l( ^% q* J6 H
} A! N) Z% E8 X8 W
`. a% n9 m# Q* n2 X9 X
</script> |
|