返回列表 发帖

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

<style type="text/css">. x' R* f6 F# `# ?# @
#supertext {
: v! k6 y& c3 U2 r1 U% _. }position:absolute;
; E3 U1 P1 i' g4 `5 N, _; c0 r: Jleft:0;
" F- {) `; q2 R$ i- z( Q8 Htop:0;
3 ]( Y' q$ O2 @visibility:hide;/ q) `7 ~( @: ]6 p  L
visibility:hidden;$ H/ J. m( \: J  x0 r! g, y
}  q- x' D) l3 v6 S) h: h9 K/ a6 ~
</style>
) p: j, L* s  S- e5 \<script language="JavaScript1.2">
( z5 A2 H; z8 {! F/ n<!-- 改变下的字体的大小。颜色-->
  Z' s, B7 U- G% j5 D! e1 M' Avar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
  k( u( e, U% G1 v- W+ v9 h# svar hidetimer='';
; v9 f* y+ {, f9 g4 F0 d<!-- 改变下的弹跳速度-->" B# \( x& t: `2 x
var BallSpeed = 20;
: |0 a  u1 u5 f! Zvar contentWidth;
: `# I1 K( b$ Y% bvar contentHeight;7 a0 G4 M/ T4 D* l
var maxBallSpeed = 50;3 ~. D. Z. u, F# l  l
+ H7 G: Z6 |" J  J  G
2 h, Y! ^, T/ M% g1 H9 w
var xMax;
4 e9 i: @3 g$ Kvar yMax;; D/ I8 A% u+ I
var xPos = 0;+ G$ B) X9 D  y8 M
var yPos = 0;( N; h1 s2 s; P% r
var xDir = 'right';
# @* V5 ~) d7 D  ^' o( ^. qvar yDir = 'down';/ C4 L% Y* a5 ]* r
var superballRunning = true;$ d6 m7 A, C& ?6 b' o
var tempBallSpeed;8 o5 ~  }. g: J* X& i: i, Z2 R
var currentBallSrc;
+ Q% d1 {5 U/ y. F( F4 [* Kvar newXDir;
% }# M, M% w' J4 f9 g1 ^+ R8 Pvar newYDir;
; e2 J& q- L( X- K, A# ]
* z9 x' @0 z0 J+ a$ D" n2 _9 O% Ifunction initializeBall() {
7 o  k! L" Q8 x   if (document.all) {
' t3 |7 i9 i: Q; c1 J      xMax = document.body.clientWidth0 z; }, Y5 X' }% r3 n$ P* l4 i
      yMax = document.body.clientHeight6 Q% u! V, F. H' I+ w1 p
      document.all("supertext").style.visibility = "visible";
1 N) m" y- Q: I  M/ {* J. e      contentWidth=supertext.offsetWidth
+ q5 R8 D! R) T: q3 C! y      contentHeight=supertext.offsetHeight9 X* J3 N! t3 T" d3 {
      }$ S4 ]+ ~" y/ p6 n$ Y0 ]6 U% ~
   else if (document.layers) {
4 F' V/ s4 S# v# w6 a9 G& ^      xMax = window.innerWidth;, g6 q& E$ ^5 v3 a0 E
      yMax = window.innerHeight;
& @$ `0 X$ f' A4 O3 ~- k      contentWidth=document.supertext.document.width7 u9 Z0 b8 S0 K9 ^
      contentHeight=document.supertext.document.height
) c- w* U8 }' ^# W) M9 y( Y      document.layers["supertext"].visibility = "show";
3 T+ Y* x5 {/ g& ]      }6 U9 _* D! m5 I" y9 {  @5 J
   setTimeout('moveBall()',400);+ a; o% [  W6 w9 h
   if (hidetimer!='')
+ A; B/ q5 P9 ^: ?- {% G   setTimeout("hidetext()",hidetimer)" u# q9 J+ s& Q: l- U! m
   }, k0 {* x1 F* ^% U% y! q

( W* K! m  a* H" l4 A7 n3 n. t/ ]! @function moveBall() {# n2 l( Q  `% A% U( o( r/ ^1 |4 ?
   if (superballRunning == true) {: ]( {  S  b" u  b% v8 C
      calculatePosition();; H3 F+ ~% Q1 M% M
      if (document.all) {
2 ~! ^: S9 Z! e, x' C$ J" I         document.all("supertext").style.left = xPos + document.body.scrollLeft;
  e8 o3 m+ H4 e' D; u         document.all("supertext").style.top = yPos + document.body.scrollTop;
% v6 L5 U+ q  z# U& D  m         }. D% `  O2 {! ]
      else if (document.layers) {
+ r' O  L4 C1 \         document.layers["supertext"].left = xPos + pageXOffset;
3 h2 A+ X: m2 N# F3 r: B5 b* {         document.layers["supertext"].top = yPos + pageYOffset;' s! H3 ~) L7 R
         }
+ M* ~5 I+ j3 ?( u( D      animatetext=setTimeout('moveBall()',20);: {. j4 L& i; g( p
      }1 P& `2 G3 N& R* x7 ]; q
   }
3 q9 ]; K0 X2 Y3 c- U! E; [* V4 t/ i" `' V" L% i4 o/ [5 ?
function calculatePosition() {
& x0 D! O4 w$ K% {: c   if (xDir == "right") {3 R/ E+ g" p6 L  R( H" ^9 r4 [8 N
      if (xPos > (xMax - contentWidth - BallSpeed)) {
' j# w2 q0 X- `: q0 D2 X9 H. }         xDir = "left";
: u5 Z0 ?, }8 Q2 i* \         }
# Q% U* [4 E8 e      }- Y+ v; B, o% `8 w, ~
   else if (xDir == "left") {+ F* }0 d' J0 W! o0 q! e7 v
      if (xPos < (0 + BallSpeed)) {/ Y5 W% D7 f$ J6 }" \9 f( d, ~
         xDir = "right";: I1 A! Y% g2 N: T6 h* s- Y" Z2 q) L
         }- I/ y5 Z4 r0 o- }# |
      }# v! ^# W" l6 z3 [7 J: ?& D7 Q9 E
   if (yDir == "down") {
/ F5 h2 b# o  A6 G: {: ?: ~      if (yPos > (yMax - contentHeight - BallSpeed)) {
. n: A' [: j* e$ R6 c4 Z         yDir = "up";9 c4 f# i/ T- a
         }3 M" \& C1 y& V; i9 W, f7 e$ W
      }
/ I/ @8 Y) c+ C4 j8 }   else if (yDir == "up") {
# q. A! o/ T/ ^. j      if (yPos < (0 + BallSpeed)) {
6 o) p; ^& ]" R$ X# j* y8 g         yDir = "down";/ L: B4 Q( u, z/ j& Q& x; ^; K
         }3 {# n% d+ E1 i# S, \
      }# O4 i5 O$ X5 t0 w9 N. P1 R
   if (xDir == "right") {% y) ~/ z; U0 V/ k5 h+ X( @
      xPos = xPos + BallSpeed;; M: A$ g) l" p7 D
      }6 R" ?7 W3 @2 ?) `3 `; }4 D
   else if (xDir == "left") {
2 l! q& w9 o. x' C1 u' {      xPos = xPos - BallSpeed;' P: I) q* g# w2 D
      }" V8 I7 b1 v$ t$ g
   else {" R2 V/ k4 H$ X6 J- p
      xPos = xPos;: w  C) ]* @$ L, a/ e2 g2 D
      }2 x$ R- F, t( _! ]6 v
   if (yDir == "down") {
, z/ ]" X# n. v      yPos = yPos + BallSpeed;- b' l( b/ q) D
      }% x5 T* J9 ]$ u7 K% @/ s9 C
   else if (yDir == "up") {
" D+ ]3 x1 U: k! c      yPos = yPos - BallSpeed;
! S1 a1 m7 r: M2 {      }
: z& M4 {- Y. Q. H! U3 G   else {
+ ~8 D, o+ y5 U9 d1 @: {: ]9 T      yPos = yPos;
. t! s; X, P% D- r  G0 t      }" L. o( r; c  C
   }
, z0 h! D; l- F' ~0 T3 d# m: r6 N- r. x3 [( V( C* o5 I) s  T
function hidetext(){. D! i8 n1 T6 L  u! o; v
if (document.all)& @" C, b# H) i
supertext.style.visibility="hidden"8 u, }; ^5 T  _4 u3 g/ a4 m
else if (document.layers)
' c6 d8 B) G) f! `* Adocument.supertext.visibility="hide"
# b/ t( K$ M6 XclearTimeout(animatetext)0 n# [+ r. l# H% c
}
+ I1 J" B0 u+ j$ s. S" u. R4 |  Z2 |! s( v5 Y; b* C
if (document.all||document.layers){
& l8 D) L) |0 _+ [document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
% [5 N7 [$ P% |; F# W8 ~0 `window.onload = initializeBall;
& P. B4 B9 u: l* [window.onresize = new Function("window.location.reload()");, Z1 R/ k* J0 S6 h8 S+ o
}
/ `3 r9 \0 e7 D. g# V; O4 e( Y6 M2 n0 D7 M
</script>

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