返回列表 发帖

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

<style type="text/css">
  h1 e) C: A+ m2 v- L5 T#supertext {) e0 `/ G. K5 O) k. H
position:absolute;
6 q8 B) r9 ]* |0 `( e6 J1 Kleft:0;
: m) \; P3 n2 q0 F! k- L9 Rtop:0;
2 }2 m7 _9 U9 t# lvisibility:hide;7 v0 u- ~$ P* ]
visibility:hidden;
+ ~! U, o, \% C8 Q! C( X. K}: n6 \, M0 ]" {( A! \! Z
</style>5 O! ^: F6 f+ `: e) w
<script language="JavaScript1.2">
4 D) |0 d7 H+ P8 e9 g% g<!-- 改变下的字体的大小。颜色-->/ _) |: r: Z5 |4 d' h
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
. r0 ]2 _& h2 @6 @  Ivar hidetimer='';) Q! m  v. f$ Y
<!-- 改变下的弹跳速度-->
$ ~8 H, H! B' N8 wvar BallSpeed = 20;
4 f5 ^8 c* Z) K. P! c8 u$ s' h9 gvar contentWidth;
' c6 \: q, n1 O4 A$ E  Avar contentHeight;
; k# p/ D2 O7 J# ^6 c* o$ jvar maxBallSpeed = 50;) j$ n! Y" a1 w+ p5 K

6 H) h7 @, \  Z4 E( ?$ j8 l  u
7 Y9 d* I5 D  c+ x6 `% @( M- H2 Lvar xMax;
* e5 D5 K2 j9 q7 P  xvar yMax;: P9 B+ M) h  ]: q2 [/ S6 e8 T6 k- L
var xPos = 0;
; X* f4 N/ g' ?( u8 Nvar yPos = 0;/ V, {9 B% b0 U# E
var xDir = 'right';
9 F( t6 b! V* xvar yDir = 'down';
9 X" A; ?; t: w4 X3 y6 rvar superballRunning = true;
* Q8 t1 n' z' m# Zvar tempBallSpeed;* M9 ^' H' R4 j1 J* E% N
var currentBallSrc;+ k$ H- I' |: `' L' a
var newXDir;
" Q6 o( C" Z( Y* W! f$ ~% s7 ~; jvar newYDir;
( j* j& h% s2 s
) @2 E& u8 y. [9 i' lfunction initializeBall() {9 C" ^5 s, k; L7 g
   if (document.all) {
8 T; ~9 y/ e" @" ]& Q) i  o3 s& g      xMax = document.body.clientWidth  ^2 T2 G5 e' V- l+ Y
      yMax = document.body.clientHeight
) ], C' r: V6 [# p  @      document.all("supertext").style.visibility = "visible";
2 \: u9 e7 M8 s1 }* j" u# h6 P; n4 A      contentWidth=supertext.offsetWidth0 |* I, [; m! s/ z" o
      contentHeight=supertext.offsetHeight
( K2 n: F% D5 b9 [$ U1 V      }
/ x/ u+ g: R% `1 f   else if (document.layers) {& ~; n& g9 g9 S, N" q) s  G  ~
      xMax = window.innerWidth;1 C# w% l  O* z. x
      yMax = window.innerHeight;& _/ t* ^. I& i4 w, C; W/ ]( _
      contentWidth=document.supertext.document.width
* f; u* f! Z8 Y$ i      contentHeight=document.supertext.document.height
, ~5 N: T+ B: ^* m8 o      document.layers["supertext"].visibility = "show";/ u0 y+ ]/ b  B/ ]9 n! W
      }
' V" U/ y" f7 e/ q   setTimeout('moveBall()',400);4 M  ]5 E; W6 G" A
   if (hidetimer!='')9 M3 L# ~- m6 B. d
   setTimeout("hidetext()",hidetimer)4 k0 q/ l- f. }3 ]  ?
   }  m3 I. M. U% q- |

3 F% q3 _* C' \1 A: P; @function moveBall() {
& d* {1 W7 v% `4 y# n; w   if (superballRunning == true) {7 _6 p2 M- [8 C- m+ l
      calculatePosition();
) R* Y$ c8 F7 S  ?6 k      if (document.all) {
& p- z  c2 G6 b3 f9 t8 [2 Z         document.all("supertext").style.left = xPos + document.body.scrollLeft;
% \) I, _" [$ W7 y4 N         document.all("supertext").style.top = yPos + document.body.scrollTop;3 z2 }% A. s: [  \& @/ E* `
         }
: a! ^$ ^3 v2 x! L& b6 D      else if (document.layers) {
; B  w2 _; F* S: P" `         document.layers["supertext"].left = xPos + pageXOffset;) E7 H: ^4 O& M" i
         document.layers["supertext"].top = yPos + pageYOffset;
9 S1 s% v! W. @5 U& M) ]         }
: l  T# Y, [# o" A; @      animatetext=setTimeout('moveBall()',20);, p2 R- V& c. j3 p
      }
, H! z- E) w; S( ?& J  Z5 P   }
4 m1 @7 X3 K* G/ J, K/ X4 L% Q) B) x9 m6 I. ^* g
function calculatePosition() {
! i7 ~! w' ^( \: n   if (xDir == "right") {+ x. d; @7 P$ m0 ~0 o
      if (xPos > (xMax - contentWidth - BallSpeed)) {
; E( l( S4 S. P/ m         xDir = "left";/ B! |) u8 s) ^" n
         }& a5 [# o' V' l8 n
      }
: M& [  D' x2 `, j   else if (xDir == "left") {# c" U( G8 R' P
      if (xPos < (0 + BallSpeed)) {- R* k. D$ `2 P9 O4 U  c
         xDir = "right";( X: K5 J' s" ~
         }
" V" U0 U/ \  ?3 A2 w      }
% A0 I6 e8 F2 M  z1 G   if (yDir == "down") {
( w# `) ?/ Z. B% s      if (yPos > (yMax - contentHeight - BallSpeed)) {
8 [8 S  H+ c9 j0 o) n  B  ?         yDir = "up";
/ G  X9 v% h" G: X) E         }- M% C2 Y; z2 ]4 k# x7 v
      }
2 R0 o1 }/ _$ T1 F! m   else if (yDir == "up") {, q2 x  ]  b: ?# O
      if (yPos < (0 + BallSpeed)) {
' l4 d# c- @: U+ {         yDir = "down";
6 q8 U2 E( w3 z; D& H         }
- S& K, K$ s( ]( R      }
+ E: W5 h+ t. u   if (xDir == "right") {
' |5 f& A5 _) v      xPos = xPos + BallSpeed;+ c/ q$ z% G/ o( r6 h
      }
3 Y5 F- f8 w+ w. n   else if (xDir == "left") {% k7 G: |0 `3 n8 b7 U
      xPos = xPos - BallSpeed;, Y" C+ [, q& |, x; X' K( ~+ D
      }
* v( _! A/ k1 x   else {
7 x( F1 R7 y: i$ j5 v# H      xPos = xPos;' N% A; q2 ~* Q; _. T
      }
5 z# ?% Q3 P/ j; N9 k1 B  ?5 L  E   if (yDir == "down") {4 f2 ^) S$ }! y' D. L% S" F
      yPos = yPos + BallSpeed;
. X$ U$ s1 E1 I      }
7 ?" o5 H9 {8 L& c   else if (yDir == "up") {' M& q, e0 d3 f( p
      yPos = yPos - BallSpeed;0 f: F  }' C- {) \0 F0 {
      }
. x! b) e9 k) @) J4 P0 `) D   else {
$ F4 d! m' h, c0 R  S$ H/ G5 d! Y      yPos = yPos;  x" B; `+ r8 i: w" b
      }4 M& R3 e7 `  h* o
   }- k$ V7 v1 Q+ w- l
6 r" K$ R; k& d3 W# F
function hidetext(){  r/ _% `7 s- ?5 t/ i- |# r7 f
if (document.all)
3 g! X1 Y  a+ [  s% ]0 k; Ssupertext.style.visibility="hidden"+ Q) M. |+ c4 s& f; u9 u. e
else if (document.layers)
' b4 j& S* s2 B* @  @" N* |, v* U' z$ Vdocument.supertext.visibility="hide"
6 [3 M( I5 y0 Z+ q6 K" D! m: yclearTimeout(animatetext)
& H! w8 m; ?4 C/ q}
' M8 y; Z  U. o2 y  B
0 B8 f& ^: B5 \if (document.all||document.layers){
4 g) V; c  R& c4 _4 qdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 A# j- |9 f5 w" L+ Z+ lwindow.onload = initializeBall;" m  a. y$ B: ?$ a# g+ G4 }6 J& m
window.onresize = new Function("window.location.reload()");
, I4 a; Y/ c, Y" ^& P" @1 v4 W}7 z/ K# u) b1 r) x6 E

/ m! a5 o0 u- C</script>

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