返回列表 发帖

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

<style type="text/css"># t- D9 w, Z3 p% _+ }
#supertext {
/ N5 ~1 R) q. A- I* Gposition:absolute;
. x9 C0 c# N& q! l, mleft:0;) P7 W2 {: M- r( k0 J+ q
top:0;
6 V( O" v' L* A, {( xvisibility:hide;9 q0 T2 Z  `' a  L, r/ }
visibility:hidden;' R/ N! z6 I' K" \9 p
}
! N; y, l8 @  P6 M2 F</style>
, D6 M& V8 L* o; z# F2 E<script language="JavaScript1.2">& e: D7 ^. p! N) I; u( i. V0 y
<!-- 改变下的字体的大小。颜色-->/ u; f7 q9 \8 {7 C
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'9 y) ?5 ~8 ~* w% K) Y
var hidetimer='';
- P/ W" D& z+ g) C% `, u<!-- 改变下的弹跳速度-->
. P6 {: p8 Y2 R$ Evar BallSpeed = 20;
! c! y  [- F% W6 ~* R% cvar contentWidth;, ~8 Z) i0 o- F$ M3 M. Q2 f
var contentHeight;. [2 t; A; k/ N% n3 [" B
var maxBallSpeed = 50;
# ]" U& {" [1 ?, U
, i% R) W" q4 b3 D- K4 b8 R9 i# d
2 J  }0 e- L6 V1 Q  {) _var xMax;
- m. \( H2 r, }9 Avar yMax;' j. V: {% J* l
var xPos = 0;" `+ N+ u* E7 o" a$ q$ _
var yPos = 0;" ]! b" u* s, e$ P# s
var xDir = 'right';3 I! n4 v9 t" q2 o
var yDir = 'down';- v: \2 ?3 B9 ~+ H% X* R) x; E
var superballRunning = true;: g2 W  Z2 ~% d. [
var tempBallSpeed;
( f% k2 d2 S$ B& X' g! Kvar currentBallSrc;' y  P  V6 p  F! e
var newXDir;
5 J' |7 w8 a+ d! h: tvar newYDir;9 F7 Y! Q- k- j2 H9 g: [" [

6 T. x7 F3 I+ Y6 bfunction initializeBall() {  V6 a5 @' y  g: I
   if (document.all) {
1 ], o1 U/ A0 o5 G7 B8 r      xMax = document.body.clientWidth
. ]0 ^& L7 X0 E1 ?, e! t4 D6 H      yMax = document.body.clientHeight) E& M- @, h  V! m6 T! S7 o
      document.all("supertext").style.visibility = "visible";5 p7 L! g; u5 U& h4 {/ q! p% ?
      contentWidth=supertext.offsetWidth
" w0 S+ I6 Y3 M" z      contentHeight=supertext.offsetHeight) K* w) \, f3 h. ~+ p& z
      }
# I1 U  x2 q+ W5 @, ], f4 z# I   else if (document.layers) {
9 q4 p) f7 w  r& ?      xMax = window.innerWidth;
( ^( N' F6 t- d0 J      yMax = window.innerHeight;. H" u1 @* J# ^9 q, _3 m
      contentWidth=document.supertext.document.width
( B5 j3 g, h8 f6 @$ _* \# A      contentHeight=document.supertext.document.height
/ F4 @% E$ S- y* Q! x      document.layers["supertext"].visibility = "show";
+ G. @5 N- i' ^( g6 C. j' k2 a' D      }
# |3 L3 d+ O' K  U7 b   setTimeout('moveBall()',400);* ^. y" f; R) ~& m4 P' P
   if (hidetimer!='')
# P$ C5 B0 A) U- l  H+ K0 f5 g   setTimeout("hidetext()",hidetimer)2 {/ |2 W5 H, q8 m0 U/ p3 J
   }! \! u& J: N1 }' ]) D4 z# C% r" W
9 Q  a# [& ^( q  Y/ A  q" K
function moveBall() {' w* h7 Z) v9 f$ k0 x
   if (superballRunning == true) {3 j7 Y" L9 G7 c
      calculatePosition();
  O! V& t- g1 k( m; n0 h      if (document.all) {
$ L- u5 |9 o, s/ m8 L' [) ]3 ?& `- j- |         document.all("supertext").style.left = xPos + document.body.scrollLeft;
2 p4 L8 ?( J! s  T$ _5 K         document.all("supertext").style.top = yPos + document.body.scrollTop;
9 ]: e7 i$ X& W! z         }1 V5 S3 X% [/ }& ?+ }
      else if (document.layers) {3 p' f: y) \: P
         document.layers["supertext"].left = xPos + pageXOffset;# ]+ r! k$ K8 D0 X$ p  s# T, _
         document.layers["supertext"].top = yPos + pageYOffset;6 |9 K! M' ~: U. z2 m
         }+ q6 g" O6 i% y% K9 E8 b! @% }
      animatetext=setTimeout('moveBall()',20);
: g1 D- ?& M$ g; P9 p% z' d5 s      }
1 c$ Z) C3 `9 E' h0 @( J  R   }
( o7 r( T# P, r  N& a( `& w8 Y, o: }. D7 K  ^+ Z
function calculatePosition() {& o% b  p1 n' T% T8 u  e# u7 \. k
   if (xDir == "right") {
# {8 g$ w$ j# y, `0 ^- {- a$ |      if (xPos > (xMax - contentWidth - BallSpeed)) {# G6 p* K- n6 l* Q
         xDir = "left";
+ p" u  B) P, e& U& y: D3 R- C         }
+ c( Q9 d' N( I9 w- l      }1 w3 V5 w5 n( l. _# p
   else if (xDir == "left") {+ a6 r; n1 c" m% ~4 N( A4 H' L
      if (xPos < (0 + BallSpeed)) {" F# a0 H5 W' N% s5 b
         xDir = "right";
: Q- d0 \8 N' d1 r0 e/ L4 q         }7 I9 X' Q/ s& {
      }/ D" [2 G! s' c0 C
   if (yDir == "down") {
. f# T% \+ u: q& t/ q% S! O      if (yPos > (yMax - contentHeight - BallSpeed)) {% t2 g/ Y1 N) `% X3 B
         yDir = "up";* n1 E3 s/ q  r) s; N: M4 A
         }% }& V, H- I" o5 T. m* r( x/ L
      }
- N2 m  f- `3 @   else if (yDir == "up") {
+ \$ A; s+ b/ z* B5 |8 O      if (yPos < (0 + BallSpeed)) {
% v0 V; A4 |" n7 N4 q         yDir = "down";
/ v+ X/ e. X# b         }
4 m1 B( B3 k2 D- k2 ?  R      }
8 d7 b) c& S# F) s; h! R" i   if (xDir == "right") {
# B6 e5 l+ l3 W- L) I+ m      xPos = xPos + BallSpeed;2 \7 L7 e9 e5 K2 f* K
      }
" E' k8 H- _8 I- Q0 f2 T   else if (xDir == "left") {
, }& B" s$ Y  r' F# G      xPos = xPos - BallSpeed;
  R" d) R' x5 ]      }
* Z# y6 _! q6 X. b1 K' ^   else {7 j* @! M# ^) ?* X6 ?: W8 h( y& |
      xPos = xPos;
/ L& M- v4 @! d9 D1 v4 D" ]      }
) A4 E$ F7 l/ G$ h4 |) `   if (yDir == "down") {, b6 i1 B, @& X+ U% D- n$ D
      yPos = yPos + BallSpeed;
. x! n! o, j+ k$ J      }/ v7 v+ O0 }$ |  @
   else if (yDir == "up") {
2 ?3 O5 j8 [' g, P5 ]) `2 n      yPos = yPos - BallSpeed;
; A  i) v) O" g' C. X3 a      }" y+ Y: @' {1 g  E
   else {2 f$ G7 y' v, b& |5 W
      yPos = yPos;. c/ }% k: [3 n9 s1 h/ O) \
      }& c, ?2 \0 Y, @* s1 k: d+ k
   }% @/ T& q4 u& Y9 K: K

' k+ q7 A/ t1 V3 V) c, Y+ Qfunction hidetext(){$ z- f/ n5 f& z% `( }0 K
if (document.all)
0 V3 L$ u: n+ r: `% isupertext.style.visibility="hidden"2 v9 {! g* r! d
else if (document.layers)
& A2 q& P$ t, _: odocument.supertext.visibility="hide"
  I9 {5 K4 s; E; J$ BclearTimeout(animatetext)2 x' z# ?  v8 U( R+ F% s. w8 Z
}+ t, G+ D* w1 P7 g  t" d
0 g4 O8 ^+ x6 a" F  S4 A- S
if (document.all||document.layers){  U: m$ ^( Z0 m9 v6 e7 Z/ x+ c
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), s2 R; j( p0 n/ J) R
window.onload = initializeBall;. q, o- E( l- J0 C
window.onresize = new Function("window.location.reload()");0 P' \! W. Z. ^! @3 ^7 [
}3 T7 P4 @2 X: W) }9 }0 ^
1 o: n) d. n( J$ |0 I
</script>

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