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

|
网页之不断弹射的文字-特效
<style type="text/css">& u8 `7 {+ i( L; |
#supertext {
" A' i9 f; G! C: ?position:absolute;
" {& `( B5 ~) C6 `/ I0 |) W$ X. Ileft:0;
9 H! c: a+ |; Q) j- o# }top:0;/ |% Z, R) C1 f7 M5 [
visibility:hide;
0 C5 M! w0 }. s! D3 ovisibility:hidden;
: q* T, y! Z2 ^3 l) f1 r}
7 h1 q; u) O: n2 y</style>9 Y E+ V s7 M3 b7 ]1 z' k
<script language="JavaScript1.2">5 e/ y; L6 Y9 P9 U
<!-- 改变下的字体的大小。颜色-->
2 t; L! G, q4 }0 lvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'+ k1 l, }& U( ~* {: M/ o
var hidetimer='';
I9 V1 ~+ Z2 |/ k- K. j4 G# I<!-- 改变下的弹跳速度-->
3 q9 X- k. ~3 j1 L/ }var BallSpeed = 20;' g2 v* B' e# y) @
var contentWidth;
$ \; e7 ^" |, R4 k9 @2 ~; A6 Evar contentHeight;1 ?% V7 x6 p, B+ C! ~1 S' C4 e1 {
var maxBallSpeed = 50;
$ m: G; t. T/ k: h8 G3 [! u7 U$ D& q5 M! H. N3 k1 X, ` U
5 m% l( ]& j, G! \4 dvar xMax;) \% p% l! L ~! @5 Q
var yMax;- d' C, g5 m! B' e. A( {8 U9 \
var xPos = 0;
% {$ m7 o5 U! v$ T* Y$ k1 \- svar yPos = 0;
. l5 w$ m( n" b" O3 s8 ^- Yvar xDir = 'right';, Y! T- p2 E# L# H6 Z1 ~
var yDir = 'down';
1 s# F# r5 \7 I, v4 D& Evar superballRunning = true;
) ` |; K0 n, R2 h& P% Yvar tempBallSpeed;
, {* u- c& P1 G/ D$ A: Dvar currentBallSrc;& a/ A5 X' d* ^$ I- E, j5 s
var newXDir;
: \( `/ @" O* e8 fvar newYDir;3 R9 m8 b* `! {' {9 T. y
; a% @2 D5 Z" j1 t5 ^
function initializeBall() {
: L1 [& g6 A% G- N8 g+ y) W if (document.all) {* v' E, D+ C( Q
xMax = document.body.clientWidth; S6 L' {; f- }" o6 {5 y- n2 d
yMax = document.body.clientHeight, p. D, w3 {" U/ T+ i
document.all("supertext").style.visibility = "visible";
8 U. ?0 h/ {1 a/ {0 k contentWidth=supertext.offsetWidth8 E0 y e; O' J! k
contentHeight=supertext.offsetHeight' H6 U2 k0 P c6 c3 ]; ~6 r
}" C3 n% K' U) e4 Y. y3 r5 W
else if (document.layers) {
! }# t1 `4 I, x A! a/ ^9 i xMax = window.innerWidth;
6 c7 V; |7 Y9 N$ x0 a yMax = window.innerHeight;6 S( `' z* Q# | u3 ]: S
contentWidth=document.supertext.document.width- R1 Y& ?/ W9 y( O$ I# n" V
contentHeight=document.supertext.document.height
4 T) V" p, D1 x2 y" N' E: I3 d document.layers["supertext"].visibility = "show";0 Y7 w0 ^' M# T, r& e$ N
}
" }% ]9 M5 F4 u) R setTimeout('moveBall()',400);( H% Q$ K, i& U
if (hidetimer!='')4 {' y5 K2 u! }# i0 o
setTimeout("hidetext()",hidetimer)
7 ?6 u+ C P& q! x& T" h, }, ` }% l$ h7 ~8 x# M# n2 ]2 U
1 `: |) z# U$ V6 Y
function moveBall() {
/ w' R) o* C0 ^ r. i: ^ if (superballRunning == true) {2 z5 A; X1 b8 T+ p8 Q6 u0 L
calculatePosition();4 | T3 g3 a% E, u ^
if (document.all) {
1 t* S& {: F+ e/ D& ? document.all("supertext").style.left = xPos + document.body.scrollLeft;: C) n& H: f: E: Y I
document.all("supertext").style.top = yPos + document.body.scrollTop;# x# F2 m) B/ r" t
} p+ `5 l3 U5 p
else if (document.layers) {8 |7 A" Q7 w' P- r( e7 q$ k
document.layers["supertext"].left = xPos + pageXOffset;! \# u2 v3 G* K( \2 F9 q
document.layers["supertext"].top = yPos + pageYOffset;& s D0 t% g/ e6 I0 A3 \
}
+ T3 h7 R8 J% H$ W$ p% T9 k7 ~ animatetext=setTimeout('moveBall()',20);
) b$ G2 S$ \. M: l }& K1 H$ L- @% n' L/ ?' }6 K5 z5 D
}: k3 |7 k0 s D0 e
! r0 }8 K3 X" bfunction calculatePosition() {% }/ t' J# A2 E9 j* o5 l0 |
if (xDir == "right") {* F* ]3 D j+ d2 r# r
if (xPos > (xMax - contentWidth - BallSpeed)) {/ R/ d$ I. Z0 G; V- M& U
xDir = "left";
; U v6 o* P, K }8 W$ r! P0 b5 h- s) H/ z+ T7 `
}
0 P0 k- x/ Y8 O7 y \7 j% J else if (xDir == "left") {
4 e1 w) u, g9 ?9 T if (xPos < (0 + BallSpeed)) {
( W9 }, R1 p6 s) [7 V2 } xDir = "right";7 |% b- L1 {, r- _3 t n! `1 _
}
" C$ L; ~, Y. q% s }9 e5 B/ [# O/ ]& U1 b
if (yDir == "down") {& t6 [5 Z$ H) b+ P
if (yPos > (yMax - contentHeight - BallSpeed)) {
1 \0 q# M! ~9 p3 s& S- O) G1 p4 v yDir = "up";
& k' x. f! g' |, ~ }
0 K: @$ e W* ?3 V" M+ V- N% p }- k6 d9 d- x9 i
else if (yDir == "up") { I( }1 i% p% M0 F F8 w" T: U
if (yPos < (0 + BallSpeed)) {3 n. z! N* u" i. U E
yDir = "down";* Z6 | @+ K) R2 ?+ F
}7 O) J- X- V' P
}. q8 X- r2 J+ q# Q8 M
if (xDir == "right") {3 x' l, {2 l& w: M3 d
xPos = xPos + BallSpeed;
% `# r0 D' a! N7 F9 H }
! r3 g- [. u: f else if (xDir == "left") {
. D W* J2 L% j* m6 v xPos = xPos - BallSpeed;
: ^! A( v: v6 B: d" c) }- `; a }5 t8 J0 k# w7 M. P+ k' L6 J7 _3 Q
else {+ f1 G& ]3 P8 i, i3 r
xPos = xPos;3 @. q8 p/ f1 S5 l
}5 j+ h' |, A1 y, D
if (yDir == "down") {
" y3 J% A% F9 V1 A. l7 ~; E! [ yPos = yPos + BallSpeed;
7 G9 ]& f- l4 P/ K C9 U5 c7 m! u! r }1 [; O3 Y( [- o' F3 a6 I
else if (yDir == "up") {
, l3 [: X- s! M! `) h+ K" X yPos = yPos - BallSpeed;+ e' ~5 c W4 T& {5 R
}
6 h# e) W& `" R5 u else {( H* k4 E5 O9 [6 l/ ]7 ~
yPos = yPos;
; I7 [$ G! q# T8 {: v }
: T. b6 t! c* ` |/ Z$ ^% F% m }
# P* v X" j; M2 j
0 K4 q4 m* S$ M+ D) i$ gfunction hidetext(){' i' A2 Z1 B) p$ p& q& K( Q
if (document.all)
5 }5 b$ w$ |8 O. esupertext.style.visibility="hidden"+ v, b3 g0 N% |4 H/ T- [
else if (document.layers)
8 C* y. W: R; i2 n5 n; \) B* Wdocument.supertext.visibility="hide"6 e$ ]- w0 k V# c! l
clearTimeout(animatetext)' V$ g2 ?2 N3 g& q; G4 {
}) R* A8 F1 z% M8 _$ J
% u( \- b: A7 K: E; q) h) C0 A& nif (document.all||document.layers){! y; a. ]0 N! w/ l
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
. L5 @( p6 |% j8 D/ T7 L9 g! twindow.onload = initializeBall;
. |8 d4 a1 T5 s1 ~. S3 w6 qwindow.onresize = new Function("window.location.reload()");
0 |. v c# `- S1 e}5 [7 M# E6 u% H1 t& Q
( Y0 @$ U) B( b: c& Q</script> |
|