返回列表 发帖

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

<style type="text/css">
9 N  v7 O; o& z/ ^: J#supertext {
9 C( w3 e( U" i( B4 H0 Q2 [) `2 Yposition:absolute;
7 ?. Y5 ~/ x4 R* y( c2 Gleft:0;
% Q0 V9 g* I' U! k; j2 h2 jtop:0;
& |" G7 {( d4 w( }visibility:hide;
( D# ~: B9 z6 nvisibility:hidden;6 d2 O1 N+ A, N* l
}$ ~, o3 E% ~) P9 O8 W1 X2 I/ b3 N: r
</style>
, D7 P1 E4 p1 N% x<script language="JavaScript1.2">7 Z" ~3 R1 a6 k+ Y" E
<!-- 改变下的字体的大小。颜色-->
7 y- w9 R% ^+ Nvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
5 y. M+ ~" ]0 A* |7 l) f" @var hidetimer='';( g/ K( M; u- v1 P0 n; V8 x& x
<!-- 改变下的弹跳速度-->
- M. m5 l' t( F5 G# Svar BallSpeed = 20;. S4 ^7 [2 q/ D$ X/ x! f/ i
var contentWidth;. n5 z; i& d# B- O" u+ T. E- V- v
var contentHeight;
8 j5 _9 P. L& jvar maxBallSpeed = 50;
8 f& W; X+ i5 u/ t% ]0 T* C" Z% [  @) f* P
/ C! y9 }/ a. z
var xMax;
9 E, n3 ]6 D2 h0 Tvar yMax;5 c& F3 `$ O" z4 k6 ^) k
var xPos = 0;
% @3 f3 e& _; U& w0 pvar yPos = 0;
8 q4 D8 d+ i/ i. m6 |var xDir = 'right';5 T% c5 D4 n% b- A) _9 f
var yDir = 'down';
+ d! Z( X/ D) b$ }var superballRunning = true;, V, V/ A) m( h& B7 j' R# g5 w
var tempBallSpeed;
. f: l; W5 e7 @. t; `- l1 a! fvar currentBallSrc;2 ]) M0 S' Y3 g/ o/ M5 [
var newXDir;4 `6 z& k; L/ Y- @% W" R  H8 \, @
var newYDir;
2 {2 L7 G* X; X+ o* I) ?  j
7 M! B7 K* X9 ?# ^5 ?5 lfunction initializeBall() {2 h& P# j! m% ?& v9 E5 g0 J
   if (document.all) {
* B* a9 t. g. G! l! \      xMax = document.body.clientWidth9 [3 [  V, m$ t4 t0 Q" {+ Y
      yMax = document.body.clientHeight* ^9 D7 W5 ]3 {( X2 Y7 Z: X8 T
      document.all("supertext").style.visibility = "visible";# l# c0 Z4 C4 T% Z
      contentWidth=supertext.offsetWidth
4 n  o; X0 t0 i: W0 O( o  L      contentHeight=supertext.offsetHeight
% v2 u" o7 ~8 x, r4 B  L  F* a2 m      }
4 Q6 x9 j) h2 L/ g: K   else if (document.layers) {" y4 o- q! ?3 j! S& X9 m
      xMax = window.innerWidth;8 o$ T  x, r4 P9 W9 F  E, ?% [7 i
      yMax = window.innerHeight;
" y# z- |: R( E% [      contentWidth=document.supertext.document.width
, d" Z$ K/ r% g* {      contentHeight=document.supertext.document.height
0 X$ U* S2 C& V1 w# `; L      document.layers["supertext"].visibility = "show";) s, R" i: F! {; _; Q! T
      }  S6 S/ S. r6 ]
   setTimeout('moveBall()',400);
% y& R5 I0 W5 q! Y   if (hidetimer!='')1 o7 p3 T5 l9 {6 v2 U
   setTimeout("hidetext()",hidetimer): e4 D2 c7 P& {
   }
2 }- o0 o' `- z: A
  [/ O. s; w4 r# [# _: O8 Y+ V) F+ Zfunction moveBall() {
: m3 H. X: y3 k2 b$ ]2 g$ c' L   if (superballRunning == true) {
8 i, Q8 b' k9 x2 y2 l" o% i) U      calculatePosition();" v$ i6 p* k& v3 v3 d
      if (document.all) {, g3 ~# q- A, j/ m. k) H
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
' J# G: ?: O3 {         document.all("supertext").style.top = yPos + document.body.scrollTop;
; O5 p4 O+ X  `- Z4 U         }( ~  ]; v8 \  u& d: T3 A
      else if (document.layers) {
$ s: P4 ?- p8 b# W8 x  u         document.layers["supertext"].left = xPos + pageXOffset;* M% G$ i9 Q$ A7 j
         document.layers["supertext"].top = yPos + pageYOffset;/ G5 \  L/ K0 O4 t. {  W# n8 {
         }& \& k6 h( e6 j  J5 U1 w% H
      animatetext=setTimeout('moveBall()',20);9 C  x: x' C0 A" K
      }
; c' B8 u6 R& S* ~. `9 g   }6 @- y; d. @5 a$ q& R
  z8 v+ p+ U: ?7 ?% C  B
function calculatePosition() {
+ b5 D1 W- l$ f+ T   if (xDir == "right") {
& D% n5 I0 F6 j1 [9 ~) B5 n6 n      if (xPos > (xMax - contentWidth - BallSpeed)) {
% M( v4 s$ V- D) q- r         xDir = "left";
* Y: e* Z  U1 ?         }  A3 f' \3 F( L( ?/ h( N% {
      }
" Y% M6 u% `+ f' c   else if (xDir == "left") {
: ^# S1 L6 ~/ [( M8 b8 k0 z! d      if (xPos < (0 + BallSpeed)) {. A# S% O" V4 U( P
         xDir = "right";* M! U# O8 C0 L9 ?% o  M
         }, `0 F6 x- @$ N: E; p$ S
      }
  `3 C/ Y5 v( E6 q2 B/ j7 f   if (yDir == "down") {
7 @' b9 C0 w# C  K! C      if (yPos > (yMax - contentHeight - BallSpeed)) {
6 o5 K" p) l; y" y         yDir = "up";) k0 C6 U* f- g5 v
         }
& m, J8 i( _7 x7 R      }( Q7 |, y! D/ D9 i
   else if (yDir == "up") {. m% J8 A7 x1 b) O7 `
      if (yPos < (0 + BallSpeed)) {( b9 f% }. w7 A% w! N
         yDir = "down";
  h- Y/ a9 P4 @8 u8 j         }
, O$ Z, Y- U8 s; r- g: m0 ?# u      }* q# K" F+ w" u6 Y6 A9 e: N
   if (xDir == "right") {
2 u- h" ?3 E2 U( x      xPos = xPos + BallSpeed;
, A6 \0 _) y4 p' \. t9 k, L5 z      }
+ a. B, G# @& d   else if (xDir == "left") {
; A; Q" u9 n2 {5 |      xPos = xPos - BallSpeed;" f7 c$ E) M3 Y5 i) a7 J& m8 o( m& |' _
      }1 m5 \; x0 ?$ E  _+ i% R& I
   else {
9 w1 _% ~4 J! v* ^& V8 l      xPos = xPos;
" H  ]8 Q1 ~- a- h      }
; |0 d) C( T. t$ ]0 j- z$ m   if (yDir == "down") {
3 q5 z* j4 R8 o+ n      yPos = yPos + BallSpeed;
6 z6 X5 d3 a) a) w/ j, _% R" N      }5 {( o" Y2 k- w* {6 W
   else if (yDir == "up") {
% N3 a! K+ Y* B: x! w; ?- A  y+ Z      yPos = yPos - BallSpeed;
& N9 }1 {1 D6 b      }% q' {# k6 r7 T: v! G
   else {; q9 `, e  l4 l
      yPos = yPos;
9 y2 G* I+ |- c: s      }1 p: k6 C& `: }6 e% T+ }
   }' f+ ]+ \9 {/ j1 u  L1 y  w* c

* D9 M/ R0 W5 ]function hidetext(){* k- G3 }# B8 {. I9 C
if (document.all)
* B* n6 E/ V' V4 V( e6 J: Psupertext.style.visibility="hidden"
/ M' M/ i% B3 x$ E( y& |& \! _3 P5 Melse if (document.layers). v4 I: e- P2 D& ]
document.supertext.visibility="hide"5 J$ J8 T! w6 ~
clearTimeout(animatetext)
" _7 v5 c9 H9 i/ _3 A" Y}* e  E+ `) u  }" F5 b" k3 l

# Z* O$ q7 l! R3 J8 d; Dif (document.all||document.layers){& Y+ z8 c9 ~1 n
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
. n/ A- m) C6 ^: p) e6 j5 Bwindow.onload = initializeBall;
1 S9 X! q" H: @window.onresize = new Function("window.location.reload()");
5 K* s5 w+ T; M}: h% M2 x0 n7 V- m5 L

3 m0 e( o: s1 D% m! P% V0 Z</script>

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