返回列表 发帖

网页之不断弹射的文字-特效

<style type="text/css">7 s4 t5 P! \& Q. E
#supertext {
) K0 G3 S; `' x: a% D2 T* fposition:absolute;2 P# v: W/ z) |' d  \: U! Q  w
left:0;4 A, C7 i3 L+ ]0 k
top:0;
. Y) B! Y0 I5 y$ V5 Bvisibility:hide;5 g/ E' N4 |5 v+ q; D! c' K
visibility:hidden;
% ?: F: F5 v( V' d$ r/ T}' {* ~* L/ P2 g% Y* W; E4 x
</style>- }9 b# B- @! ?8 w& I
<script language="JavaScript1.2">
# k% O, f" R, Z7 s4 S<!-- 改变下的字体的大小。颜色-->
. O# t( u9 Q6 i: _var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'/ A0 p$ w" a% Z8 K
var hidetimer='';
, g5 U& b7 O4 ]% @<!-- 改变下的弹跳速度-->4 n9 l4 ~. l# p0 R$ d2 U7 p. K
var BallSpeed = 20;0 c% r  j/ a+ l5 l' \
var contentWidth;) r2 q. Q& C) b6 f. a6 T7 F8 C
var contentHeight;0 o  H' f1 D. L
var maxBallSpeed = 50;1 d* z2 _4 _9 c3 n2 V$ Y% \

6 s' d; v8 n% ^. T1 S( E$ ]" X6 f( j/ ]. Z6 S) L! x9 \4 {
var xMax;- S% Z5 Z( _# O+ U2 Z/ W( G( o
var yMax;
. w% Y+ ~+ Z7 Uvar xPos = 0;* B- [- s/ E6 e
var yPos = 0;3 O7 H$ ?9 P2 u1 N+ n
var xDir = 'right';
; q. j8 D1 [6 h3 ?var yDir = 'down';# |/ L5 n) A% |4 E8 A0 a* L) T5 ]
var superballRunning = true;
$ z0 ]- e1 P1 Y9 Gvar tempBallSpeed;
% l" x6 X9 W5 K4 r* \& ovar currentBallSrc;3 g' ?4 q- C+ n% m! g
var newXDir;8 l6 ^1 ], _5 Q/ d
var newYDir;
$ K) K4 J) O6 x% e$ [) j0 N. u5 r* y* R0 _
function initializeBall() {% V, Z$ p" G3 u6 I& Q
   if (document.all) {
* y: ]: v% W1 W, t5 s      xMax = document.body.clientWidth
5 f4 l5 \2 l: ~! U6 l) b$ @- C; q      yMax = document.body.clientHeight
0 s5 m0 }, I) a6 t7 p      document.all("supertext").style.visibility = "visible";
6 {# H9 g& K( m      contentWidth=supertext.offsetWidth% w' e  U5 L& Q) ]) R
      contentHeight=supertext.offsetHeight9 k; E* g1 C* Z- ~) m  v
      }
7 p6 b8 b7 [7 X, G$ k9 N   else if (document.layers) {
- K' y8 t. d/ F0 [      xMax = window.innerWidth;9 _7 v5 j: z$ r+ e( s
      yMax = window.innerHeight;
+ `6 u/ `1 d' y  x# }      contentWidth=document.supertext.document.width
+ g. ^+ ]# u1 ~  q; I      contentHeight=document.supertext.document.height
8 v3 B1 p- q# N  A4 T      document.layers["supertext"].visibility = "show";6 S/ L& A! h" k! a1 _& q
      }
; w7 {, e8 G7 \   setTimeout('moveBall()',400);
8 M0 J6 U/ T- ^' i   if (hidetimer!='')
' ]8 L& w2 c" u/ H" O0 t3 {% ?% n   setTimeout("hidetext()",hidetimer)
+ e; \3 B/ L, B  {( h   }
# a, _6 \& ~+ {5 m0 r/ f4 }, T$ D0 V: X5 y. _3 W0 N
function moveBall() {/ L! r% r; m+ E$ N6 \# [( _" U6 `
   if (superballRunning == true) {2 y# _7 {: L/ ?
      calculatePosition();/ L5 G7 |! J0 e+ m
      if (document.all) {
- ]2 L& f- |6 X0 v* E. P         document.all("supertext").style.left = xPos + document.body.scrollLeft;
4 ]+ u4 w6 \5 ^2 g3 I         document.all("supertext").style.top = yPos + document.body.scrollTop;1 I3 _: S% V  [: V2 M# d( k" n0 H
         }
6 c& r- h+ M) r$ S7 o% g$ d5 A1 ?      else if (document.layers) {1 ~# g" y$ Z5 Z4 l9 |3 X# Y
         document.layers["supertext"].left = xPos + pageXOffset;
7 p7 T# J; z/ g9 c4 g0 q6 [         document.layers["supertext"].top = yPos + pageYOffset;
* I; s, b- M5 X0 e2 y1 }- ^         }% p4 i9 f5 |5 l* H3 a1 S4 s
      animatetext=setTimeout('moveBall()',20);' `# |0 R; m7 `
      }3 X( A' r9 j: t6 M7 X' i- a
   }/ u, H2 u0 m9 z& m5 o8 h
0 N# _6 ~# M3 A
function calculatePosition() {
4 z; ^0 \( ]& g! R) p& K; }$ S5 A   if (xDir == "right") {1 z! V6 @7 g8 @' R* [2 P
      if (xPos > (xMax - contentWidth - BallSpeed)) {
5 |/ ~+ C0 u# ~         xDir = "left";( F# S  H% l8 o- }
         }
5 p6 \& N2 w& ~; S  q0 n1 i7 L      }6 g( t( }7 \- f
   else if (xDir == "left") {
7 I* {) f1 x9 H: C$ h1 k: P      if (xPos < (0 + BallSpeed)) {
2 y. e* l: l0 ^$ c8 E* i         xDir = "right";0 n; G: P( E9 }1 x4 F* W; j/ T: G
         }$ S+ F+ f2 l9 ^( V; y
      }
! y4 ]" H% g% n! X( W8 \* T   if (yDir == "down") {
; n4 {3 U6 U& E2 D4 h8 Q) z      if (yPos > (yMax - contentHeight - BallSpeed)) {7 u# H$ A9 d9 S, s- R' C
         yDir = "up";
' o, h. M' @" v/ v/ J2 D) \         }! ?5 e! x4 J. k
      }
* |+ _$ E8 L! Y% U8 q- ?   else if (yDir == "up") {
- N! x. R3 V9 d9 V* \2 G3 q      if (yPos < (0 + BallSpeed)) {' W# z% a3 k3 j; M& E
         yDir = "down";5 p* C1 v- W. ]
         }
1 S9 `  U% g3 J6 ]/ \/ f      }1 _4 l& U: J4 w3 c
   if (xDir == "right") {
" k( _- s. ?/ e) ]$ d      xPos = xPos + BallSpeed;
  s6 ]" S6 ^8 I( @% Q( C      }- w, y9 m! l9 N$ I4 Q
   else if (xDir == "left") {: l9 s5 ?- t: m! k% \* e9 p8 k! V
      xPos = xPos - BallSpeed;
6 t! m, S; Q) |; o5 x      }
, m: I  [9 V  c# e. `1 j" F- e  ]   else {
. F9 Y& y+ b: [; I% w" M      xPos = xPos;
9 ]& v: j% L+ F8 n+ s      }
' _. o/ l6 b& M$ `. @* N1 x   if (yDir == "down") {
( L+ |: c. g6 t$ p8 x9 z- P      yPos = yPos + BallSpeed;
+ y# t0 G- i& r" L      }8 v+ k0 |( x7 g- Q* A
   else if (yDir == "up") {6 |. E% J1 w7 p$ o4 y3 r
      yPos = yPos - BallSpeed;+ G8 ^! P5 l; u* q7 K0 _  C' F
      }
; T2 X* X; X% @1 @+ q   else {# ~% R: ]$ ]% U; A5 i. H0 E
      yPos = yPos;
3 g7 S" m: L: Q4 u' V4 P8 E      }
0 p7 L- E) l) @# }! s3 U: j$ C   }
! a. o/ V! p0 `- i8 r) a- T$ v" {7 g9 e* N
function hidetext(){* v( I7 x' _1 n& v! J& O
if (document.all)
4 C: s# B8 i7 l3 w, A4 w. Jsupertext.style.visibility="hidden"' W( C- u8 u+ S. g
else if (document.layers)
+ K- k/ p, r7 i2 G# Rdocument.supertext.visibility="hide"1 \) {( a  v" g/ Y* e
clearTimeout(animatetext)0 O# E) l% C# X* R5 n0 b: l& f
}+ B+ n' @1 @8 M6 J$ L

8 m+ l2 A9 s% `& H' t# Lif (document.all||document.layers){
$ e% X. W  X$ z# v8 h. \document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')5 u6 p! N5 {0 o+ o$ P' T3 L: `9 C
window.onload = initializeBall;
0 X2 a6 l9 U4 `, f; r) }. Ywindow.onresize = new Function("window.location.reload()");6 N4 d) `) u# U9 V, S+ o
}
6 V! E3 E% P3 O. s3 W" {* B! T9 f. s8 _
</script>

返回列表
【捌玖网络】已经运行: