返回列表 发帖

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

<style type="text/css">8 L5 y! y3 C  A: {9 J+ K0 n0 D
#supertext {, W. J4 W# _6 w* O" Z, g! P/ @
position:absolute;. V$ B* O4 z1 {( W5 {# `+ u) k, x
left:0;$ S! `, P; i, }2 r' e% T
top:0;! O  `3 N/ W. L  d
visibility:hide;
! a1 n" ^( j4 W/ Z- xvisibility:hidden;
- o4 ?% I# C. v5 J- f}% j5 `1 K6 K: w: m! Y# M
</style>7 m8 ]. O, s( w' V
<script language="JavaScript1.2">5 l4 _5 I5 [: \3 J3 d  e! O
<!-- 改变下的字体的大小。颜色-->
, {& a6 D* o7 k* H& b, g8 evar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'0 S) e% _$ c$ _% s. M
var hidetimer='';
5 w9 v7 X* ?7 x7 q, S/ i<!-- 改变下的弹跳速度-->$ }  A8 {, b3 L/ c: L2 o
var BallSpeed = 20;
3 E' n9 I/ f6 w% ~2 W4 ~6 D& |var contentWidth;
  w1 x7 ?1 Z# \" s; n2 lvar contentHeight;
- L( C& g1 w/ ^9 lvar maxBallSpeed = 50;- l9 w: x2 H/ {# G4 H2 _; v

' E' m* I1 _' d7 s. x" ]+ A" K" j' d) A" k# O: G
var xMax;
+ e# u  C; w" l2 v- i, |. g+ Z0 D: jvar yMax;2 s# A4 c4 J3 h$ s2 p% f
var xPos = 0;
( }% ~* E7 C8 u" wvar yPos = 0;  B4 z8 D7 k; f4 H
var xDir = 'right';
/ N( Z5 A8 i, ~" Gvar yDir = 'down';7 o8 v6 ~! ^0 j$ L+ p
var superballRunning = true;+ q3 E9 [0 Y% }* D3 [+ h8 k) b+ ^
var tempBallSpeed;
7 Q7 v, n4 c' t# \8 Y  `9 {var currentBallSrc;" l" f, T1 w5 n+ [1 T7 L0 ]
var newXDir;
# e( \! S+ A8 M$ G1 zvar newYDir;/ _- ?& p; H% T5 n% W7 L: B

! p1 K" {3 e3 @2 D$ V" rfunction initializeBall() {& C4 b) s* b% p; c- b! t
   if (document.all) {" @# O2 ^: J( u8 U/ Q+ W, o
      xMax = document.body.clientWidth# X% H4 i. Q4 m' A' \
      yMax = document.body.clientHeight+ O* A" E- m( g5 z+ y
      document.all("supertext").style.visibility = "visible";# t# H% y' G5 W7 Z1 A4 A6 |
      contentWidth=supertext.offsetWidth0 R; O: l* P' |' d- D3 O8 ^
      contentHeight=supertext.offsetHeight% y% Q% V. l7 r4 k5 `5 H1 z
      }( {: i! I; H+ B3 J
   else if (document.layers) {
2 [0 S6 J4 l) A      xMax = window.innerWidth;1 C5 O0 ~6 V: X4 `2 V$ c
      yMax = window.innerHeight;
. _2 a  L' B8 H) f" A8 c7 K& p      contentWidth=document.supertext.document.width
2 y2 ]  p! I' _1 _7 G" M( M      contentHeight=document.supertext.document.height
" ]* ]9 I9 E' s' ?$ G      document.layers["supertext"].visibility = "show";9 _1 H* g: W8 @% v
      }
) {) q0 j, V  C7 s- t$ X5 P   setTimeout('moveBall()',400);
- S! K1 V6 c, [   if (hidetimer!='')
% ]* F$ v# u8 e& O4 P5 q   setTimeout("hidetext()",hidetimer)! J9 [2 d# h* C) U8 ?, C
   }3 y6 l/ ]3 ]7 T1 G+ q

  V- d( J9 ~3 r- ^) E" Q( k. vfunction moveBall() {
. i5 @8 Q# J0 g: m5 ]% }   if (superballRunning == true) {
3 ~6 J" `( @$ d1 a1 R$ `      calculatePosition();
* \5 t( L0 P9 n$ G      if (document.all) {
( ^. z6 k! |  Y" N2 D! Z" g& n         document.all("supertext").style.left = xPos + document.body.scrollLeft;6 }7 m9 _4 U3 z( U8 C& ?
         document.all("supertext").style.top = yPos + document.body.scrollTop;7 V% b6 X3 ^1 u6 C- W" B
         }; P( _4 G2 p% `8 T$ d9 ^# }, |& y
      else if (document.layers) {' h) i2 \0 _* f1 r% N) ?
         document.layers["supertext"].left = xPos + pageXOffset;' z- v, @+ }3 n' H1 t8 n& B
         document.layers["supertext"].top = yPos + pageYOffset;
& T# t8 q( B3 F# p- g         }
" Z; N' L, T% ~! y# c/ O2 S+ s      animatetext=setTimeout('moveBall()',20);
, l6 a& \1 k4 f' V      }
8 L* F/ f5 j9 M+ q, Q+ l   }
: k; u* Q  @5 F% v( e5 a! ~2 n7 q! |+ p6 B2 D& u) X% n4 M8 P
function calculatePosition() {( V! r  o' P: o0 k
   if (xDir == "right") {
. ~- I- C3 b1 `. s; N" H9 _1 P      if (xPos > (xMax - contentWidth - BallSpeed)) {
# ^- z3 T' k0 i7 @         xDir = "left";# d- S* N+ A# |% s. q  E$ P" z
         }& e) o0 J$ b- d
      }
4 x. Z, G) _' y7 @   else if (xDir == "left") {& m# F; L: D' U, W+ Q/ m" A4 D
      if (xPos < (0 + BallSpeed)) {, A( |' \0 V& T+ V
         xDir = "right";! j1 L+ r& c8 x5 B# \
         }
) B  V/ j4 M" ?/ O* X. D1 Y% @, ?      }
* r: h9 _' Y6 y   if (yDir == "down") {# w" ^4 `- w( J2 e+ F
      if (yPos > (yMax - contentHeight - BallSpeed)) {
. C# _) z3 {5 l! E- Y( q         yDir = "up";& H/ i- }- J: G! p
         }
  _4 \  `6 U9 M/ [: E      }
/ i+ P1 }8 u4 z2 f   else if (yDir == "up") {& D8 {* }: v) o# J# D$ h
      if (yPos < (0 + BallSpeed)) {2 A! \, P4 w. d1 y  A, b: ~5 L
         yDir = "down";
) y% n, h2 ^7 V1 I) {9 N. {5 _+ I4 c         }
( [* I! v# E2 {  s5 f      }
6 a$ l  m5 D5 g$ U0 \' F5 z/ {   if (xDir == "right") {
) }8 Z4 g- ~6 c- l( @+ B+ n# T      xPos = xPos + BallSpeed;, w2 G$ q4 [* k5 t; R
      }
! W7 j; z9 F' c. }* i   else if (xDir == "left") {0 E; f- [7 D2 L2 Q7 V; [/ B) @$ [% Y
      xPos = xPos - BallSpeed;) C" T' f" ^# |" @% q5 D0 X
      }
) W" @( \% F" _6 ^/ y9 `) E   else {* A0 w, X8 B' o( x( O
      xPos = xPos;* K. k9 ]( M4 Y# a0 I
      }
) ^) s: y9 |' K/ G& R. F* l   if (yDir == "down") {
6 i' R2 v6 I( a# @/ n- D# Y5 T      yPos = yPos + BallSpeed;
4 i+ ]# W/ N0 c# c      }5 ?2 h* U) [! Z" b1 t3 j" E
   else if (yDir == "up") {. U& A0 I2 C/ u1 ]9 a
      yPos = yPos - BallSpeed;- R" T2 y& A/ x) S3 j8 l
      }! r5 Y0 o1 B, M  |2 T% c
   else {
" ^8 m2 J) {) `      yPos = yPos;
+ u) j$ i* U' j* ~' V" M) g      }% O% t1 ^. l) Y6 B
   }1 r7 P  w: C  M( m

" {0 Z8 c3 w! s6 [6 F6 h2 W# Yfunction hidetext(){
$ W7 C# P$ A" \- A4 Pif (document.all)
2 ]" y4 W0 X* P) vsupertext.style.visibility="hidden"
/ g. O2 A4 v7 J3 S4 ~) Celse if (document.layers)
# k5 X$ p. a, e. Qdocument.supertext.visibility="hide"' ^6 f3 T# o$ \  T: `
clearTimeout(animatetext)
; N' A3 y( a& d8 R( a9 O9 S}
3 Q, [' ~" D# |3 l' N! s; P" S  p, P: ^  `  C' q' U9 _
if (document.all||document.layers){
" b" o) s% [' X  [$ `# cdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'), Q7 D' {4 ]2 x/ [3 ?
window.onload = initializeBall;
$ o! m$ U: S7 e' e3 u# Lwindow.onresize = new Function("window.location.reload()");2 l" S# @/ M! J5 Z
}
3 h$ n* h1 _. R% }4 S+ l" j3 e& r' l9 `2 v! b( p4 e
</script>

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