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

|
网页之不断弹射的文字-特效
<style type="text/css">
8 h# z* |; w! z8 U: N#supertext {
2 T1 L n* T7 Bposition:absolute;1 h8 M3 B# ]& @' G
left:0;
- @. B8 c& L5 Qtop:0;' F& r' F; J$ O5 \* C
visibility:hide;
: y; [7 Q8 h) C tvisibility:hidden;
# a/ A* X7 C% u" r1 z}# W1 C: P, Q+ X* @
</style>, H% o1 |2 z) B! B7 a" x
<script language="JavaScript1.2">/ {9 U8 N6 p5 c8 j! E3 M
<!-- 改变下的字体的大小。颜色-->
6 k w7 U" ?( G3 f- Jvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'3 S, Q4 ]" C, d3 M; A. X" V9 ]
var hidetimer='';8 {4 v# u- T0 v: u
<!-- 改变下的弹跳速度-->
+ M; @5 }3 t; p+ x% ]* Cvar BallSpeed = 20;: f5 E B8 i( t# B, K9 ]
var contentWidth;
8 Q& y6 L, e8 n/ I! H+ Evar contentHeight;# _2 t4 ?- P9 \* g2 w
var maxBallSpeed = 50;
. u! p8 |5 ]1 I3 A- y7 {' o/ Z" A% i3 R
6 ~/ c8 F F7 Y" i+ V- ivar xMax;
$ p% | ~- J# Z: Z" Wvar yMax;3 H4 H) O, [9 s
var xPos = 0;
8 r7 S' u# R( k3 O6 [var yPos = 0;
5 k8 D4 r" H; r- f& Bvar xDir = 'right';3 s* X7 c, B# I1 Y7 T
var yDir = 'down';
5 L0 `: F" H8 D" b0 H, pvar superballRunning = true;
1 i& q; q) J6 ~, y- J) Qvar tempBallSpeed;7 y# Z$ A8 a& g+ _9 q8 p+ t) U
var currentBallSrc;7 G4 n& Z" X( h2 Q6 |- Q9 b
var newXDir;
8 l- d9 V: z8 Uvar newYDir;
4 U# S% c- s$ A" L, x9 d J) E
1 j$ t; b) B9 Z2 p% p! X; ofunction initializeBall() {
$ ~( @* X6 l3 N& B9 a R if (document.all) {
0 u% O& v# e$ N9 Y3 ~ xMax = document.body.clientWidth
7 Q: _6 M) w, } yMax = document.body.clientHeight: |4 w* K# B. D' C2 a9 |
document.all("supertext").style.visibility = "visible";+ ?4 z( k& e5 S6 v7 R5 _2 _3 c
contentWidth=supertext.offsetWidth
9 a# D" g3 a) X9 |4 k# M& g- x contentHeight=supertext.offsetHeight7 k6 B8 [0 u9 P! X0 r( N
}, \. M9 ]& X8 v+ M( A4 X
else if (document.layers) {* z1 F0 L1 d3 F8 l* _0 {& Z
xMax = window.innerWidth;& h1 n/ p$ [/ H1 J
yMax = window.innerHeight;
4 `0 f" |0 L' Y( r% C3 I2 M: a contentWidth=document.supertext.document.width
' Z! a7 L: f' x' z% p) o) x) g# L contentHeight=document.supertext.document.height
6 {5 B+ a4 _. N3 ]0 o1 L document.layers["supertext"].visibility = "show";! i B5 s: R7 b$ N4 m
}' b' X1 C# a* O/ O9 q! g, W
setTimeout('moveBall()',400);
1 _5 D9 B9 B% M* D1 b0 d: v if (hidetimer!='')
8 h" b- h3 E5 j9 y& E5 s setTimeout("hidetext()",hidetimer)
8 l2 V. N7 I% f4 n }% ?9 h$ h' i$ l6 [/ n+ \3 v, A
. W" |2 B8 o! S( Z
function moveBall() {
- r5 c/ ^( o' C) c+ I if (superballRunning == true) {; u5 w+ J" J9 E, w1 u/ J2 ^4 O
calculatePosition();
* f8 e/ A! m- p( d' g9 {. m if (document.all) {. r4 V' A6 x: d+ U S$ E8 K* S
document.all("supertext").style.left = xPos + document.body.scrollLeft;
1 B' Y4 C, r1 `% a+ n2 i& Y) g% P! m document.all("supertext").style.top = yPos + document.body.scrollTop;
' R& C- }; J c3 w& x }8 ] ?- q& R9 s- E' d1 r$ e
else if (document.layers) {
; J4 O& D2 a1 _5 G document.layers["supertext"].left = xPos + pageXOffset;
, ]8 {2 E9 r+ l document.layers["supertext"].top = yPos + pageYOffset;& y8 T1 w) Y# B! H
}
' x! w7 {. [2 _% B animatetext=setTimeout('moveBall()',20);
" m x& d. F( {! P5 n; X }5 G9 z5 O& V+ H7 _
}, p" m" }$ c, p; t3 g2 } H
( J0 ~& h6 f& \# P/ i3 C" u, q ^
function calculatePosition() {- w2 |3 L; D$ B# u
if (xDir == "right") {
+ m' {& {% e4 Z' {+ `, Q2 x if (xPos > (xMax - contentWidth - BallSpeed)) { q8 r' z' p- m
xDir = "left";! h9 n! J9 [6 S, s" k. \+ f. U
}
$ T# d! K. i( a; c }
6 f, L/ B3 _, T0 y5 z else if (xDir == "left") {
3 A! \2 c9 C% Q( W2 ?/ `( b$ z4 @ if (xPos < (0 + BallSpeed)) {
/ {) U& l8 z0 h xDir = "right";
0 V7 F+ Z g; h! ]6 D }
5 j" R& V5 S0 ~8 J* Z( z }) k1 j& k. ^" I+ b
if (yDir == "down") {
% e: ~/ {# n9 x( t if (yPos > (yMax - contentHeight - BallSpeed)) {
5 A* z, }. n5 v! w yDir = "up";! e3 l( S" g( x, T& o0 i0 p: H
}
1 ~: H0 e9 P" r }. t. b# a# N7 \2 S2 S
else if (yDir == "up") {1 _: w/ A" o* m) M" Q3 E( I
if (yPos < (0 + BallSpeed)) {3 W0 ^# k+ i- J J! @% ?* _% }
yDir = "down";
, M2 |8 v! k1 K% K/ h# l# @ }
( T0 I7 f: s; {1 d9 \9 Z3 N8 D% q/ Q }' i( i! S4 ~8 i9 R/ `8 P8 k
if (xDir == "right") {. ^0 M7 N! z) c+ k' P1 M! ^
xPos = xPos + BallSpeed;
, U8 [( Q0 U3 e }' C. z. ?3 h8 V0 s" {
else if (xDir == "left") {1 m8 C/ F. P% X; ^
xPos = xPos - BallSpeed;" e6 |3 Y/ u x$ }' a3 k; r
}7 ?2 t( U9 v6 r) q* Z
else {. u4 f7 f! U8 o+ f' H2 k0 V- b9 w, w+ C
xPos = xPos;
4 V+ y0 c1 p1 h8 y) E }
0 r* J6 i5 o" Z0 c if (yDir == "down") {
3 U. d, A1 [% {: J3 S" B yPos = yPos + BallSpeed;
* F* Y6 E$ {. y }6 m" Q- ~2 F+ G) R( L
else if (yDir == "up") {
! h/ u6 @ H1 H" [ yPos = yPos - BallSpeed;
) N' r$ A/ ~+ N, z1 Z t5 y | }
) O0 I! {; M8 N8 T8 s- k8 B else {# n0 T+ ~: Q# r" E
yPos = yPos;8 ?1 A2 A% P: @# [1 {7 n1 ~/ {$ N
}
& y2 O% ~2 o* x8 ?% j* t0 O u }
* A1 q/ H2 A2 g" f+ v; j: p1 |: n) c5 S' ?3 z4 b
function hidetext(){# y. B% o7 ?. @* R
if (document.all)
! \6 ?: C' \! q) W- {supertext.style.visibility="hidden"2 h2 R6 E! e& [
else if (document.layers)
# y$ o: H- {- F! Y; D" fdocument.supertext.visibility="hide"
2 {) I0 ?- j5 }4 Y) a; aclearTimeout(animatetext). K* k2 f6 \ k# p9 V
}, v0 V; P- `; O, e; N( \* M
+ g ^' V/ }+ J8 L4 [if (document.all||document.layers){
1 b+ |' p' [8 {+ Y/ g, xdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
! E8 X e0 H K' X" v- Pwindow.onload = initializeBall;# L7 B2 X3 k4 M' B. w
window.onresize = new Function("window.location.reload()");6 L' I$ R' Z+ K
}: S2 y4 |) y4 ^
2 |- u3 a7 D4 ?' ]% V: s* t/ [</script> |
|