返回列表 发帖

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

<style type="text/css">
6 J8 X. D9 c7 I& k#supertext {
$ `1 U4 R5 J# O  J  aposition:absolute;
2 v9 t; X2 R/ p1 W) X; x3 A9 U5 yleft:0;
; k9 B! E3 l+ r& M' Ztop:0;
- @: @5 X4 k" P6 P) w6 [visibility:hide;/ D- ^4 _: J3 }. g) g, h
visibility:hidden;6 k- H8 ]' k3 ?2 o# g3 a& r% w
}
. l/ j% g  x2 p</style>
4 u! k3 S( j$ |" l' M  ^6 x<script language="JavaScript1.2">/ {: j7 d; Z: D2 E: K# a% b5 ~# C1 P
<!-- 改变下的字体的大小。颜色-->
. f& h! E" w) y2 F% hvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'* J3 S7 [9 ]' h. X" R3 J
var hidetimer='';( v, z1 Z1 n! W3 T. x2 l
<!-- 改变下的弹跳速度-->
5 ]5 F& d  X6 a- O5 C; U( bvar BallSpeed = 20;8 b+ Z1 y- I+ j# q: k3 I: I+ R5 q
var contentWidth;" f7 B: D) V0 {7 K/ o
var contentHeight;
7 e. f2 n; {0 b5 ]6 b7 ?% L% Avar maxBallSpeed = 50;
3 q0 w9 M/ O0 D( U7 z
! I7 `2 s8 n+ l/ }2 E6 s, w& k' q! R. W# y
var xMax;3 L2 {  F$ X* q1 |; s6 F8 T
var yMax;0 Q6 D& T: t4 C  u1 p
var xPos = 0;+ V- _6 L% o* a2 M# ]
var yPos = 0;/ A0 Y8 F" J0 K
var xDir = 'right';% R" z' E& K) y- {. V+ C  L
var yDir = 'down';
: W1 K% ~  {( n. ]. P- E7 ivar superballRunning = true;
: ^8 ~9 O, N2 x& Gvar tempBallSpeed;
4 {5 k: S4 X3 hvar currentBallSrc;( G- }8 I$ d- w: x, N
var newXDir;. |! P% `- h( p! d" J
var newYDir;9 V% `; Z7 [9 x" w) R8 ^1 c
/ _! T$ C" ^7 v. w. X+ x
function initializeBall() {
3 z2 s! f! ?5 x2 Z0 i. I5 I   if (document.all) {
1 @. }) z4 e9 x, Z. h0 ^# b      xMax = document.body.clientWidth
$ L# E$ F5 I/ W) P2 W5 I      yMax = document.body.clientHeight
  G: {; [3 n( n1 L      document.all("supertext").style.visibility = "visible";2 f: ]1 n8 K% \- S
      contentWidth=supertext.offsetWidth% ?. O; i+ c! ^7 L8 V! K  j5 l, q
      contentHeight=supertext.offsetHeight0 j8 |6 s( Y4 O$ f
      }3 p! G( l( ~1 E, d
   else if (document.layers) {
) h6 d' Z+ j0 w& z+ X+ E" k      xMax = window.innerWidth;
  |* ]# l  @- b# q; N      yMax = window.innerHeight;
. Q- L- g; A8 @& H8 g7 R8 G  b      contentWidth=document.supertext.document.width
, |0 @+ G7 F! Z! c6 p, f; a' J9 W      contentHeight=document.supertext.document.height+ t# Q( k1 j; H$ i0 o$ E
      document.layers["supertext"].visibility = "show";
5 I- ]1 z  ~. {( m3 {6 `- b      }5 i+ c; K" l$ X$ P( F  E
   setTimeout('moveBall()',400);
' Q6 H5 o! A! b; h: j8 g% ~6 ~   if (hidetimer!='')
) A1 E, }5 z( K2 q4 H& f8 X1 _& t   setTimeout("hidetext()",hidetimer)
4 R0 d7 l4 l/ V& o& b4 x   }5 ?8 |9 v& R# E; W$ @

: h" r7 y  E' ~  Hfunction moveBall() {
( I$ c( _" D" E2 e1 h2 a* i, O   if (superballRunning == true) {/ B# O0 A6 R# C+ d7 w
      calculatePosition();
# A! H" A2 Q% S& V+ u      if (document.all) {
; I  H" z% y$ Q# R2 M         document.all("supertext").style.left = xPos + document.body.scrollLeft;) ?: v0 \8 Z8 L* _) K
         document.all("supertext").style.top = yPos + document.body.scrollTop;
: l! q6 H$ Q' p         }' S5 y  f4 F' U3 w
      else if (document.layers) {( q% P, e0 q% ?
         document.layers["supertext"].left = xPos + pageXOffset;
7 i, y) O( D  k; z: ^0 B         document.layers["supertext"].top = yPos + pageYOffset;
! j* T, `/ ?. H0 u/ ^         }% ^, Z# x  r2 B; z( [
      animatetext=setTimeout('moveBall()',20);
* ]+ B) c/ c8 ]5 i+ @1 b& \      }- s. b% t6 S- Z0 K5 m+ T$ Y  T  Q3 j
   }4 E! ^5 X) F9 Z0 b' a% N

0 ^( x: B3 Z6 c+ M( Q9 w3 i- ofunction calculatePosition() {
8 B3 V6 b+ N9 f2 v7 Q9 Z7 @   if (xDir == "right") {
$ r) k' _, B8 i( Q- K: I! c      if (xPos > (xMax - contentWidth - BallSpeed)) {- m6 y. I7 {( r, m
         xDir = "left";7 p6 s' l2 \- y; b+ i0 _
         }
* b4 B' n* s: b* \      }1 D( N7 a! t$ E, e3 R
   else if (xDir == "left") {
! x4 |* D, F# M# I+ D$ E3 q% R      if (xPos < (0 + BallSpeed)) {  _7 C& F$ f# O0 ?& u
         xDir = "right";- L. [0 Y) c5 E) s
         }
9 i/ _* S' k0 s! e      }
4 i3 k3 U9 f  I& d- A) y4 ~  z   if (yDir == "down") {
( B  Y- B- b5 u      if (yPos > (yMax - contentHeight - BallSpeed)) {
8 O1 u7 R0 f+ T         yDir = "up";: n/ v  j4 x# K4 }3 f) s
         }
) c- g+ b0 @3 N: M5 u9 h  U      }6 [5 o, E- \6 m
   else if (yDir == "up") {2 h' Y1 ^5 q  H" l$ i3 r( L. u' y: e
      if (yPos < (0 + BallSpeed)) {
# G$ R1 `3 n( m# d( _9 F; _         yDir = "down";
( m" E  Q0 i6 i5 A         }
0 h/ l! O. V( K" R$ i# R/ W      }0 x% E4 {; E- O+ `
   if (xDir == "right") {+ ]( t" Z# k. q1 ^! X. Z
      xPos = xPos + BallSpeed;
! A/ R8 P7 \, G8 g5 o' y( V) }* `* R      }" M  f  j6 z& q$ c
   else if (xDir == "left") {7 H: [( [) J: l' B! K
      xPos = xPos - BallSpeed;8 V0 S7 {4 \$ H" u% P6 e. Z+ k
      }
% R! w# B# P8 p/ B/ |   else {! s- j8 K  ~+ a# g
      xPos = xPos;+ R0 w  }* _+ Z* O/ W) Y
      }. [  |+ [- b7 c9 B  K/ i7 O# Q
   if (yDir == "down") {6 }# g( w$ \: w. {) O0 g
      yPos = yPos + BallSpeed;
6 }. E7 b( K$ j0 P! M) |( c) c      }
. Y0 [( E0 D. q* o% e7 F7 a3 V   else if (yDir == "up") {7 F  {, r% `+ I) a' N- K
      yPos = yPos - BallSpeed;" k6 ~% e$ j/ P4 U) ^- S, A9 R5 V
      }
! q( c5 j, Z& h6 H$ i+ ^, }   else {
  l* @. ^/ y3 D; @      yPos = yPos;; O* [/ f; B: n/ @' L% o( o+ a
      }
, z/ N9 G; b& N* w  W   }
# Z  \9 x' |( B( P8 i2 s2 J
: g& }: c5 M7 H, Mfunction hidetext(){
: |$ \1 G$ k' cif (document.all)  c. n& b9 t' ]- B$ I+ [) H
supertext.style.visibility="hidden"
) }" E$ _/ Z4 |" t  V- m( z3 helse if (document.layers)( b6 p: P+ E0 F  f0 G. D7 K0 R
document.supertext.visibility="hide"8 ^: C# J( X) Z2 m
clearTimeout(animatetext)" ?9 [5 z) [' Z$ t
}7 D( W0 r1 w+ l- f
* U" {# i5 n# x# l8 ?% b  H
if (document.all||document.layers){* Y/ y7 R, }3 g% r1 d' ?& {2 Z; f
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
0 J! m7 j: I8 X5 K2 c  Zwindow.onload = initializeBall;
) j2 m6 M4 U& p8 Z/ q8 I0 Jwindow.onresize = new Function("window.location.reload()");* C, a. a+ a5 e+ K8 p$ z
}) @2 v- e2 w7 s# W

  y8 D. ?$ a6 O% s6 V</script>

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