返回列表 发帖

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

<style type="text/css">
9 ~1 `" w+ \6 I3 t#supertext {
, G- }# X3 a  B4 A( A8 qposition:absolute;
& y2 h2 F+ D. D8 L1 t) _+ Hleft:0;
/ v+ X% Y6 b# e# `2 c+ ]& B  stop:0;! s( Z( `  f- V+ w# c% r, A
visibility:hide;" \- A1 c7 t0 H8 Z' S
visibility:hidden;
" J. {# q) q: p# f7 x& T}
+ }, u* i) r$ A/ c5 f' {! l</style>
0 Y2 k* E# Q" Y- l! i7 g<script language="JavaScript1.2">
" O$ a4 `3 \1 Y: ?6 Q$ ~; m: i<!-- 改变下的字体的大小。颜色-->
, l8 X( c* t0 l) V3 hvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
. k, W* Q  Q. [! b. W+ }var hidetimer='';
' q& Z/ s4 I, h0 C9 S# W3 b<!-- 改变下的弹跳速度-->
+ }% k( G3 m( f( |/ Rvar BallSpeed = 20;  p- ^. {0 Z: a1 w& [: Q
var contentWidth;
* w  q) T$ |2 H: hvar contentHeight;& `# H$ e7 z2 ?
var maxBallSpeed = 50;
, b5 i# ^  V; N4 U2 [& F  H: v4 N$ I5 ]. N& r' C

/ X8 U  d* w' Z# |/ Q& w- w+ o; D. o$ yvar xMax;
% y. p7 {( Z6 Dvar yMax;
& f( _2 P0 S# h5 e; w1 a: w$ Wvar xPos = 0;
, `9 {7 }4 P; W0 [. avar yPos = 0;" Q+ p& K# p* R1 ?8 L$ {! V
var xDir = 'right';* r& u/ x& }/ u! e- C2 e. T
var yDir = 'down';. ^3 L$ @/ o* f1 ?2 Q
var superballRunning = true;
; I6 v; @* P' a9 y# Cvar tempBallSpeed;6 ]# M! B1 E' Y9 A3 `
var currentBallSrc;% }) p. s9 |' {4 R
var newXDir;
) R6 q& ~- [# Y) a7 Mvar newYDir;; ^- t# E/ J& W9 D2 U) M  a9 L7 v
: ?' \! W- e; _7 I7 ^, U
function initializeBall() {* c& m7 T/ T! y8 Y$ y
   if (document.all) {8 h3 Q1 v, y! c' T3 E
      xMax = document.body.clientWidth- G7 o/ x8 ~# f- _! t
      yMax = document.body.clientHeight
" N& S/ J" ^/ z5 D/ v' o      document.all("supertext").style.visibility = "visible";/ C" C. K) d1 a$ r% X
      contentWidth=supertext.offsetWidth7 N0 {5 }5 F+ i- Q8 D/ k, b
      contentHeight=supertext.offsetHeight+ ^: R' g! z6 |; U
      }/ _/ R# z0 u7 Y  t* Q
   else if (document.layers) {4 Z# Q  C& K& y3 E
      xMax = window.innerWidth;9 J/ B0 A2 d3 g3 `' o
      yMax = window.innerHeight;; I" w$ d3 l8 x
      contentWidth=document.supertext.document.width
3 t  H4 _4 D/ z      contentHeight=document.supertext.document.height
) e0 F2 n+ @! W( p5 q2 `' {; `      document.layers["supertext"].visibility = "show";' r" D7 u# t7 C! v& b; Q9 H
      }9 a; V1 I0 |2 Z! v3 f4 \9 _
   setTimeout('moveBall()',400);3 y+ T) ~, J+ p' k
   if (hidetimer!='')
0 }' f; f. G4 z; q6 l   setTimeout("hidetext()",hidetimer)
9 ~' I" E4 T1 c# v  D' r) Y   }1 X' f* `9 m* ]* p3 \; n  \) U0 ~

7 J5 z- D1 h1 k( ^9 ~function moveBall() {+ }2 V- K; b- E1 n" K8 B$ y) Y+ ~
   if (superballRunning == true) {
; A: z( P$ x/ ?9 F: ]: ]      calculatePosition();
. \9 g1 y6 Q9 p) T      if (document.all) {5 a* B- D4 A( a: m
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
1 }* o' K8 k5 n  D. \+ j% N         document.all("supertext").style.top = yPos + document.body.scrollTop;% U3 |: p4 I" q& g- `0 P
         }
3 {8 B# Y' S' L      else if (document.layers) {
2 V7 A# {6 P5 j1 l         document.layers["supertext"].left = xPos + pageXOffset;
9 L, H: J4 j$ w         document.layers["supertext"].top = yPos + pageYOffset;
5 o  H- [" L1 I, `3 @7 s         }
/ f! ~/ g1 x7 }6 |% b      animatetext=setTimeout('moveBall()',20);2 @( U0 L3 a, l  V& _
      }9 F" J+ u! z9 K% ]
   }
$ B- F* {$ [' O( Q7 x
( _: S2 h% Y1 ^function calculatePosition() {7 g+ l* Y) G0 c/ b& a3 q+ s
   if (xDir == "right") {
4 c8 n& l3 r5 J# ?& S; ?4 ^      if (xPos > (xMax - contentWidth - BallSpeed)) {$ E, }( T" d8 W/ z; }: P
         xDir = "left";
* R  |% F$ I  U1 s4 r8 y% Y         }: K8 k  p4 y8 Q& h
      }
. q  w& K1 r6 D" h/ R   else if (xDir == "left") {2 _* [2 G6 G! {* F( A' I1 |
      if (xPos < (0 + BallSpeed)) {5 n4 Q% v: _% [) B* _
         xDir = "right";
! D* F# [1 A9 b8 q2 ]5 @         }7 h, X( g7 H' b3 s  R
      }
/ \- b% r: ?% P- }1 H$ O   if (yDir == "down") {
0 I3 S2 H+ H2 r8 q) w% r( P      if (yPos > (yMax - contentHeight - BallSpeed)) {/ R5 O- t; }- W# e: y, L
         yDir = "up";
. M, `6 q  A. s$ G& C7 _         }
7 U8 m3 g3 |& ~5 ]8 z      }/ c: p; I$ H; b4 b* R2 J
   else if (yDir == "up") {
3 u7 D6 V: Z9 a+ ^      if (yPos < (0 + BallSpeed)) {1 J: O' u2 p: V6 M' z( H
         yDir = "down";
* y# U" O/ T# v  l$ {$ a7 a         }& y, s1 G. {" D) p
      }
: r/ [) U( K& P$ T) S4 a/ Q$ D   if (xDir == "right") {* _7 a+ {( w1 A5 c, @, C, u
      xPos = xPos + BallSpeed;9 e2 L, T1 a3 _
      }$ x* V3 T' L6 h8 c6 l& l# r
   else if (xDir == "left") {
6 r2 F! \, [5 b1 h8 a, `- |      xPos = xPos - BallSpeed;
1 N; s- U: j: f9 n+ a      }
; L5 B# h( @& j! m6 F   else {3 n: Q0 n6 o( q+ A' Q
      xPos = xPos;
3 i/ {4 y2 l1 V( e      }' |! k( S! p6 k) K
   if (yDir == "down") {! R. M1 n2 ]# W: v
      yPos = yPos + BallSpeed;
, B' h7 ^4 _& f: |      }7 D" _- L( T) P. n: C& b) a. b
   else if (yDir == "up") {$ L" v" a  c% |! T% X
      yPos = yPos - BallSpeed;+ u. k: w" b: n+ `8 A
      }' r4 e3 ?, U8 l1 g
   else {
' ]: z! U; z% |) @0 P      yPos = yPos;
( M4 \$ \7 A: C2 |# e# C( q2 m0 @7 u      }
" M+ p* C( J! w   }
3 n6 _: h8 e, E( l0 d( g
, W/ b/ B/ w8 R" P- ifunction hidetext(){, G/ V0 L8 J, Z1 d9 p& G
if (document.all)
* C7 {1 w0 [+ h; }/ |supertext.style.visibility="hidden"8 y! K" A% d- B! T
else if (document.layers)
# u& w( o" G/ Gdocument.supertext.visibility="hide"
# I; o8 U2 t' v0 p5 UclearTimeout(animatetext)9 S. a+ k2 r) U6 Y( @, |
}
/ c8 K( {  _  `9 j5 x/ V  q( B
6 M$ w( A- L5 a& V; H$ Qif (document.all||document.layers){
8 U2 \+ F* v9 W1 }; `$ S' Mdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
& f2 ~2 O# Y: \, X% G" E# }window.onload = initializeBall;2 M& ?' p1 F5 x
window.onresize = new Function("window.location.reload()");
1 _- O" R" w" I+ h$ }" y, }}
/ B9 b6 Q# x' A* d7 m+ Y0 a- [* a. o& X2 j9 f+ ?4 ]9 r) s/ P
</script>

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