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

|
网页之不断弹射的文字-特效
<style type="text/css">
( }, ^, ^. u- L#supertext {
* V% S# U1 b% N0 f" U7 V9 zposition:absolute;
D1 j9 _2 S* E* wleft:0;1 M, T* [2 ^; z% ~3 L
top:0;
4 w* ]) H% R. Z3 S/ Uvisibility:hide;
% Z8 U+ X$ o$ A; ]. m) C# qvisibility:hidden;
1 r' @4 Y M! H9 q}
8 H' S4 j3 ~5 s& U1 J3 k</style>& g: @* Q! X3 @$ ^$ Z' b7 e5 I3 `
<script language="JavaScript1.2">
: V' I5 z2 Q6 r<!-- 改变下的字体的大小。颜色-->) c& ~ w3 B3 C; b) `
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( X" }; i$ I% P# Ivar hidetimer='';. S2 B% X+ z8 J9 d9 ]
<!-- 改变下的弹跳速度-->
7 j4 B3 X% V6 I2 M# P- W, ^var BallSpeed = 20;1 L" b+ j' t5 X
var contentWidth;
! V# a8 Q7 q* x) Zvar contentHeight;: P% D% _, u4 X- b4 y. Y/ D
var maxBallSpeed = 50;
( R+ t+ z+ [+ G5 u# r& b5 a9 P4 q* ]2 ]0 _! s: N% F# A
9 \* {5 ~" r: B. u+ N {" evar xMax;
& Z) n5 s1 }; y ovar yMax;
K. _7 x( n- S1 g3 e" F7 _: X+ k+ nvar xPos = 0;
4 s5 r) c8 D. i+ |% W; {var yPos = 0;& w5 O% S2 M4 R D0 d& |3 D
var xDir = 'right';/ d# z& o& W6 ]4 v7 r( c- ?
var yDir = 'down';
# ^; N" a$ [# h' Avar superballRunning = true;6 f+ T+ _$ Z- z* [' X, _: T! k
var tempBallSpeed;+ N% s: L% F. u$ J* } @
var currentBallSrc;. J* A; f2 ~- F n" r6 L
var newXDir;7 M7 a$ R- }# G& G, c
var newYDir;6 T& D @1 {" k
- y$ ?: s4 t' hfunction initializeBall() {/ q/ _3 c) d# Q: V* I9 J, b; j
if (document.all) {
: |! V, K4 `8 O5 ~2 e4 p xMax = document.body.clientWidth; X+ \, E7 [; S0 w4 s
yMax = document.body.clientHeight
, Y1 Q* @7 O- U document.all("supertext").style.visibility = "visible";) b& ?# _4 c7 O
contentWidth=supertext.offsetWidth
& @5 s( k0 I' g1 t# m+ O contentHeight=supertext.offsetHeight
2 P/ f) p, x9 @ D3 m) @6 | }
/ \. M1 @. N- U/ [ else if (document.layers) {" C8 L5 M, \% Q0 I, a
xMax = window.innerWidth;# e/ h' q2 p; a! x, |1 p! G8 ?: \
yMax = window.innerHeight;) `6 a5 [" t6 Q8 Y2 @' g
contentWidth=document.supertext.document.width
) z4 I. g: `4 y9 ?4 O6 ` contentHeight=document.supertext.document.height
7 k8 \1 g0 U$ u" Z; ~9 u: C( ^0 q document.layers["supertext"].visibility = "show";+ @, e2 h" _1 W7 I
}
; p/ `+ h$ {2 i setTimeout('moveBall()',400);
' C) A: Z, a B( D# ~1 L8 X if (hidetimer!='')# t; I$ y- [0 r. t/ J0 t6 f$ n5 P
setTimeout("hidetext()",hidetimer)" ]* ^$ u; }& c3 l
}2 v# T" i: |) P4 ?: e6 K" d W
' H9 w# s! o7 m. e/ P
function moveBall() {
+ f2 b2 N' U( q" A3 X0 ~ if (superballRunning == true) {. b' J. W, w$ Y8 Z0 d4 M3 Z
calculatePosition();* X/ q1 m3 X: k$ X
if (document.all) {
% `; Z6 c; b3 J& c. P5 a document.all("supertext").style.left = xPos + document.body.scrollLeft;: _/ s% }; u8 d0 f- w$ G9 O# c
document.all("supertext").style.top = yPos + document.body.scrollTop;
: ^; ^( B6 D$ H }
# l; N3 T: ~$ B else if (document.layers) {' @) z2 Q! t5 h! v+ o! e
document.layers["supertext"].left = xPos + pageXOffset;
v7 t2 g2 F6 C2 h1 m document.layers["supertext"].top = yPos + pageYOffset;
& z/ }+ b6 ?' p( q8 O3 j! i }2 {5 S3 h. e: I5 e ^& W! O
animatetext=setTimeout('moveBall()',20);4 F+ T6 y' g3 {1 Y* ]7 c, Z; O
} z9 ^- o8 Y# [% q) A% q1 U& O
}5 _$ P% Y0 A* S+ F6 y. e7 M, M! I0 B
% f7 x: V& Q- i0 g( ~+ m6 q
function calculatePosition() {: c+ i3 C5 T( F5 v. X
if (xDir == "right") {& U: _" Q! u9 n5 _
if (xPos > (xMax - contentWidth - BallSpeed)) {% |5 s3 c5 q7 o) C2 E9 L5 g
xDir = "left";, j9 n' ~ ]' h
}. ], `0 w6 ]8 N+ w- ^
}
, Q1 g1 {, R% N p: a+ J else if (xDir == "left") {) `* {2 {$ w5 _7 o6 C
if (xPos < (0 + BallSpeed)) {
% @2 g( @5 `; m3 \2 z" u xDir = "right";
6 D1 j: o/ {) p) l }
4 ~8 ^# P% T# ~ }& V5 d6 |! l! M# B3 S
if (yDir == "down") {
3 D' Y. W3 u4 i if (yPos > (yMax - contentHeight - BallSpeed)) {
6 P0 v5 k4 Y' u$ M! @2 Y2 L8 y yDir = "up";
, f" G6 \0 @1 g0 K- l+ Z }
9 L( X2 e9 P+ H* b }
# X6 v1 w7 G' q6 Q) l6 {3 e' P4 Y) | else if (yDir == "up") {# I9 ^ s/ c' w: _, c% W1 }% E
if (yPos < (0 + BallSpeed)) {
7 p4 M7 x% z! L" @' S2 e; j yDir = "down";, n$ Q, p4 a, v" @
}6 w: S& h% u( I. k% V
}& y y0 d: O, x3 O) T
if (xDir == "right") {9 z* k8 P9 b# z4 D1 M
xPos = xPos + BallSpeed;7 [6 V* ]9 {* O, _' r8 y. W
}6 s; g) e, W! d) m
else if (xDir == "left") {
& h3 p% L# h: {. {( D" S2 C xPos = xPos - BallSpeed;8 s' z% Z) o. q7 D
}' N: C% Y% n. d% E
else {7 {6 `! p6 a1 @% n* l V
xPos = xPos;
( X' G$ _3 q/ _$ J }
/ ]5 M7 G3 Z# d, p0 o if (yDir == "down") { x# d1 K Z- F* L# |# H; y. O" }# |
yPos = yPos + BallSpeed;. P( ^5 B$ ~% k' I( z, O$ R
}
% M l$ C$ R9 c' g. I else if (yDir == "up") {6 Z5 u4 a& `8 ?
yPos = yPos - BallSpeed;
1 k; h7 @ `, Z' `* w }& S$ p) Y2 n2 b. B' k: a
else {
6 Y& e) i9 V0 |4 C, q6 u% d yPos = yPos;
9 N3 u7 `- b% R9 u }
d4 s5 L) G3 n2 C7 A. [: Y }9 C3 V. R/ o" {& P. k- q
7 Z @$ T/ ~9 v. l( E% j/ wfunction hidetext(){
+ Z2 L: ^! E2 o/ \. a8 {" Dif (document.all)
7 _. u& U6 x2 ?% \supertext.style.visibility="hidden"& c7 x4 U8 u# {
else if (document.layers)9 \( D7 P9 q Q9 j/ M5 d
document.supertext.visibility="hide"2 ~$ `, D7 L) X/ h; A/ e
clearTimeout(animatetext)
! z# |# M3 C+ i6 V% n& H}9 |* R& q( g' M% i* z
3 o" f# \. m5 h4 x- }1 e# cif (document.all||document.layers){8 V( K3 R( R( [
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')6 F% G8 \, Q: n V
window.onload = initializeBall;
, K- i* f- ?+ O: J5 rwindow.onresize = new Function("window.location.reload()");4 D& O3 Z5 R# n5 U. h1 s3 ~
}' |3 |) d, W# q+ R5 v) E
3 [ F3 J6 X4 [( ?; n
</script> |
|