返回列表 发帖

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

<style type="text/css">
# u7 V' B: k2 e" F#supertext {! g/ _, `) g/ z: a! T( o
position:absolute;; o1 B& t' R! Z
left:0;
! S+ q( M' d1 x, O2 ~* ntop:0;8 l) A9 ?; |/ Z, D8 F
visibility:hide;
% `8 s+ [2 o9 Mvisibility:hidden;
3 S7 @  N2 O; y% [8 t* w; V. N8 J6 _$ L}- J4 M, A2 N/ A/ w& E. Q& f
</style>
' e2 U( I  }! V. F) k<script language="JavaScript1.2">! X" c; I& |# N6 h5 g9 Z" {! D
<!-- 改变下的字体的大小。颜色-->  t2 {- Z" B- X8 N/ a
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
' I, Y6 n8 S7 s1 X) pvar hidetimer='';% O- D& u8 {; H/ }8 {, `
<!-- 改变下的弹跳速度-->
, w/ c6 o+ Y5 Z& r7 Hvar BallSpeed = 20;* c' S' \" B2 o* T/ h- [* m6 r
var contentWidth;
5 D# E& b) P$ hvar contentHeight;3 H& A5 K$ ?7 i$ K( K" \
var maxBallSpeed = 50;- j3 ~9 j, S( C' N8 S8 X# R

; [0 w& D- v3 J
9 d8 `* Z: \' c' ]$ bvar xMax;
3 V" k+ w. o8 w; pvar yMax;
8 A$ _* y$ J6 b7 T. B. L( k' i, Mvar xPos = 0;" G* F' c, a( `3 T4 o. R
var yPos = 0;
. u+ `, D# f* z) B+ uvar xDir = 'right';9 x, H# j; p* x; u# V% {4 u
var yDir = 'down';+ M' v) {* O1 a; S" q
var superballRunning = true;  ~- {' @" j' x4 m+ G/ G
var tempBallSpeed;
7 @: E# }2 M, L+ a) tvar currentBallSrc;/ O8 B4 V) w3 u- D
var newXDir;9 D2 T7 I* Q5 e# h' h, o
var newYDir;
. U. m3 K( P$ @* Y" K2 b' P* i5 D- {/ j" i2 m% C  A
function initializeBall() {
+ N4 c6 N3 S1 I" m   if (document.all) {2 p, a$ e% s8 |& [; D6 p4 R
      xMax = document.body.clientWidth/ _; h) Z5 }2 B9 _/ @
      yMax = document.body.clientHeight
6 E0 Y6 J: [, W$ s      document.all("supertext").style.visibility = "visible";! k4 N+ f3 \/ t% s8 x; v- E2 {2 n
      contentWidth=supertext.offsetWidth, |$ D, p0 ~7 o; ~& {2 d
      contentHeight=supertext.offsetHeight* u: ^, _$ L" w+ ^; H& C
      }0 i" m- A$ A0 f* l
   else if (document.layers) {
6 v: U! I3 ]# u- O) R      xMax = window.innerWidth;
- ?: `. H; I$ N) p      yMax = window.innerHeight;! ^* S# Z/ U$ ^) R  U' m/ c
      contentWidth=document.supertext.document.width
# x$ o+ T. l1 S/ b      contentHeight=document.supertext.document.height
- c6 X& K6 ~4 ~% d& Y# P      document.layers["supertext"].visibility = "show";
$ U( P+ _: s, J0 C' |$ ~6 A      }! Q  u& T( V; b6 W/ y
   setTimeout('moveBall()',400);; J; Z2 L$ Y; A" [* R& o/ A& I
   if (hidetimer!='')2 G1 ]; j9 R* m/ g2 w
   setTimeout("hidetext()",hidetimer)9 g5 X- c' M" L% J0 U
   }
2 P) k% A( {% S& d5 S
: J  r  O6 |* |4 O# X) ^8 bfunction moveBall() {: a+ C$ H* U9 \$ u6 m/ y
   if (superballRunning == true) {4 F( W! r6 R' t7 W: n
      calculatePosition();
+ l+ c/ H( q1 L, J9 p1 Q" H      if (document.all) {; }# }8 k6 t) r! c' h- D, e
         document.all("supertext").style.left = xPos + document.body.scrollLeft;" o1 y4 E$ B9 w0 W, \9 L
         document.all("supertext").style.top = yPos + document.body.scrollTop;
, j2 v; O# S. k' q3 x% [         }5 e  {& |+ y: B# R, T6 t. B. l5 L& {
      else if (document.layers) {
1 `2 R& N8 {( t& ^         document.layers["supertext"].left = xPos + pageXOffset;3 p, V" j* \0 x! [4 D" e
         document.layers["supertext"].top = yPos + pageYOffset;: U/ b+ O8 |9 H" Z
         }  g3 K. R; k' d( S& P& d
      animatetext=setTimeout('moveBall()',20);
9 p' \. z" ~) O      }
4 Y4 u$ A6 b* l   }
2 p& l* L' M' g% L2 v' P/ z3 ^7 S7 F/ ]( G: f9 n( L
function calculatePosition() {
' d6 x! A) N! N9 [   if (xDir == "right") {
4 O" h; q3 S1 t" A( g      if (xPos > (xMax - contentWidth - BallSpeed)) {( I- r. N5 c! A" w( r1 y5 {
         xDir = "left";
/ p. v7 M& m$ \" X& X2 T0 [         }8 Q2 J! G; L2 X3 a" k8 K2 F6 e
      }
4 A! F3 f+ K  j% j& J6 b" k   else if (xDir == "left") {- T0 ?/ C2 e5 n, @
      if (xPos < (0 + BallSpeed)) {* C- S4 d) w7 k( F$ m" }
         xDir = "right";. w  Z1 E' w) u  @+ y
         }
# D1 `% a9 ?3 f% f2 }$ O      }/ Y% J8 P1 s5 Q9 E
   if (yDir == "down") {
; ~0 y& P5 j7 Q. H, J% y. E, B( \. M+ a      if (yPos > (yMax - contentHeight - BallSpeed)) {/ k2 F. e: e. m% _; m& G9 q# L
         yDir = "up";
: b0 R, w: D+ A" j5 G         }
: d! A/ P4 Q) j4 |% H. [      }' x. G5 ~0 X" g: G' f
   else if (yDir == "up") {# U2 p6 ?4 ^4 D1 w3 P1 P+ E- ~$ x7 v
      if (yPos < (0 + BallSpeed)) {" ?- x/ x5 a) c0 T) ~- p& [
         yDir = "down";
  H, _" i+ {  m( m. T) Y* l$ ^2 |9 n         }
1 ~  j1 ]& M2 Q, V9 v- `      }
0 N$ G) |0 _; x. _( _$ a+ }   if (xDir == "right") {
9 j' S& k( t8 I8 ~& W* i      xPos = xPos + BallSpeed;
3 z7 y* p3 r/ E1 d  ]      }
# v; H, G: @  G  V" d& y% |: e8 P   else if (xDir == "left") {
" b- c8 w* k0 o+ R" Q      xPos = xPos - BallSpeed;. u  o8 b* L6 t2 Y" |6 N9 y
      }" j* w9 |2 n4 ^: c1 R& y$ t
   else {. l5 E2 g5 ?+ D
      xPos = xPos;) a& I7 o9 z1 ~. o- K, b# \& n6 A. K
      }# `- h; Y  T8 u' c
   if (yDir == "down") {1 t( j. o% D, i4 y, V
      yPos = yPos + BallSpeed;/ v2 Y0 R- m  |0 ]% G1 V+ c
      }. p' G' l' Y2 V
   else if (yDir == "up") {5 {! I! l. i9 B! p' ]  S6 B/ v
      yPos = yPos - BallSpeed;
4 X/ t; V: `( i. ?      }
/ k1 ]% J& S, {  [7 l3 O   else {* y" Z* p, R# g. ~3 i. j0 [
      yPos = yPos;# K8 ?$ U2 O( {. a# e- R2 D' d# X2 h" ]
      }6 G$ m1 y# j3 q8 a& z
   }
5 V* }! c8 o! b! O+ t4 L4 S- f- [/ h3 C0 r  ?! ^
function hidetext(){( \! @+ x1 W# A% r. ]3 W
if (document.all)( A7 B4 F) p& r( H: |" w
supertext.style.visibility="hidden"
) v0 M% k  E2 b/ }else if (document.layers)3 {( j8 z6 r& L2 z; n% }; W% V
document.supertext.visibility="hide"
. E0 H0 F$ L6 h) f; S9 v2 RclearTimeout(animatetext)9 y& V+ U3 ^( o& n) p5 U6 Y  l
}/ A, ?/ `0 _5 T
. I2 i1 L, ?' n" n: e  b; u
if (document.all||document.layers){
- T& s: V; J# c2 M0 l) g( idocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')& g3 B0 |) \5 I5 u' }
window.onload = initializeBall;
  b- v2 u7 u2 @% Xwindow.onresize = new Function("window.location.reload()");
9 g" }  O* D0 ]( I# ^}# b8 Y1 B  E6 Q) w( o
" C7 x* k3 P4 O8 d; O  y
</script>

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