返回列表 发帖

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

<style type="text/css">
7 I1 d3 r# p% \( @$ M; z6 S9 J#supertext {
1 P. E) `1 m0 [/ G6 _5 `* f$ Aposition:absolute;& r9 r9 b; g8 k6 r! D
left:0;
" A7 _% I6 N) [top:0;
, l' r8 ]# n- ?2 F6 Dvisibility:hide;
9 E9 j+ Q* I3 ]visibility:hidden;- V1 `: G0 G9 f/ I
}
" [4 v1 O% e! v- u& i</style>
  P' O1 `4 X0 l0 q7 `<script language="JavaScript1.2">
. T. p1 M+ E% ]<!-- 改变下的字体的大小。颜色--># y4 }1 c- w- w4 {2 t; [
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'4 j* {; e4 N" Y7 _& E/ J
var hidetimer='';) m, Z7 `( W2 J' x
<!-- 改变下的弹跳速度-->: i4 j: G- f+ X. G- q
var BallSpeed = 20;8 D$ c# _7 @# h% M0 Q2 c" K, {. ~5 n
var contentWidth;9 |* z6 Y  D: m- w* y0 t' k9 l: t: R
var contentHeight;
& p! J! c; i0 @& W: U) M- ^& `& ]' cvar maxBallSpeed = 50;
; A2 w3 t3 b7 z4 E$ E9 V3 r6 c2 P
2 p0 n* u( C, s5 t
7 y% O+ i- ?* ovar xMax;( m+ J* Z2 J4 T8 z6 v) M5 Z
var yMax;3 ]# f, i0 B  n6 e
var xPos = 0;6 u* y- f, |8 {4 K8 f1 v
var yPos = 0;9 D$ I! |5 B, ]5 g9 D- K
var xDir = 'right';& X' C# @" R/ M
var yDir = 'down';' h0 R0 T6 v; {( o3 j; t& Y3 u
var superballRunning = true;
4 m* Z7 g% Y, W7 B' G5 w0 o4 H2 Dvar tempBallSpeed;
3 z. s) P* B8 qvar currentBallSrc;9 s& l2 }' O+ f: }) O" F- M( o) V
var newXDir;
6 Y: `2 z$ m& Fvar newYDir;8 k" e( y& G4 H

/ y) x, |: V5 N  f* jfunction initializeBall() {6 t2 X  C2 Z9 ~% y4 [7 v
   if (document.all) {
( s  B+ d8 k" o1 v: m1 Y" }' M      xMax = document.body.clientWidth
/ o: c; ?- a/ y: {' g* Q$ Y# Q, a      yMax = document.body.clientHeight# N" X* S. n5 b! C* @8 J# J8 O! \
      document.all("supertext").style.visibility = "visible";
, R$ ^* ~% ~( l* y% I, Y, q& q! I      contentWidth=supertext.offsetWidth
2 d, P; m2 v6 q9 x: B& Q8 J      contentHeight=supertext.offsetHeight
# C# K0 l3 u  N9 t! n2 A# f6 s' `      }
: I3 n9 N9 q' V! f; i$ U   else if (document.layers) {) N& x  g$ M" [
      xMax = window.innerWidth;# P) E  e& f1 K- u
      yMax = window.innerHeight;
1 |, H9 A. g  @( H- u+ y! P: J, z" E      contentWidth=document.supertext.document.width
; e2 Q' r2 H" N5 ~8 U8 N. R+ p4 y1 ^      contentHeight=document.supertext.document.height
* `1 u% m' o4 g7 C      document.layers["supertext"].visibility = "show";( F9 }6 E% W' ~' R, r  B
      }
8 b9 }; N& g) C   setTimeout('moveBall()',400);  x, @8 a+ X- O7 x; q4 @
   if (hidetimer!='')
: S, |5 ~9 `. S4 l6 }) B   setTimeout("hidetext()",hidetimer)
# N% N8 E) W0 X) V   }' v9 r+ U9 k. z5 N% k3 w& ~+ h3 x- X
- b* X! @2 Q! e  c) `# Q/ i
function moveBall() {
7 a. C9 B2 A) m2 _; v   if (superballRunning == true) {
# L+ |4 k+ ~) o      calculatePosition();8 i9 Z$ w; y3 n
      if (document.all) {
7 f! i/ w! C5 `+ ?         document.all("supertext").style.left = xPos + document.body.scrollLeft;
4 T( D! B  ^( ?         document.all("supertext").style.top = yPos + document.body.scrollTop;* Z& T) G6 f* a& b8 G
         }
# k, C2 a  U5 B' V# q      else if (document.layers) {# a: \, v; s7 g  V$ k  C) X
         document.layers["supertext"].left = xPos + pageXOffset;7 h6 }+ T4 G1 z" Z
         document.layers["supertext"].top = yPos + pageYOffset;6 P) \9 J) c7 H
         }
, h8 K# C+ [  y0 C  M5 `      animatetext=setTimeout('moveBall()',20);
7 ]' M6 \1 ~! d. o& h/ p      }9 k4 N7 f& v- r; [+ l1 b  C; _
   }& g$ W" y7 Y! p/ v% X

4 @4 Q" ~; R/ G1 S8 V" X5 s, H" Qfunction calculatePosition() {! \7 Y& A. J: A$ }7 O
   if (xDir == "right") {. |  G' ^% l6 P' `
      if (xPos > (xMax - contentWidth - BallSpeed)) {
; A6 B2 \/ V% t8 a         xDir = "left";8 [8 v4 v; }1 W+ ?6 c3 ?, K: o
         }% H0 Y% u) m" _% j; t# ~
      }! C3 j& d0 y" m& c! s
   else if (xDir == "left") {3 r5 ~8 @. L) `1 }: p( X
      if (xPos < (0 + BallSpeed)) {
1 C6 r- N, p4 n         xDir = "right";/ t. }, K( f5 ^9 J$ T* t
         }
( V& T% I% M" H7 j      }
' k% {7 b$ p5 G- Y! M2 x   if (yDir == "down") {
2 L  R  p# d4 J5 `      if (yPos > (yMax - contentHeight - BallSpeed)) {9 f4 z9 d6 D1 a! Q) B  R
         yDir = "up";
# t8 N9 E& }! u         }
/ h, _+ \3 m$ o      }
& ^/ s: c$ D& ~! f& S2 E  \   else if (yDir == "up") {
) q5 w! o9 o- I, r$ j      if (yPos < (0 + BallSpeed)) {
. _+ }4 I+ y9 V         yDir = "down";
6 |8 L, A- R! ?% B         }) X5 |; I/ J  u) u% Y% p
      }$ x1 x# G7 Y& F
   if (xDir == "right") {( F' P$ ?. f  n8 M% v, ?( ^4 K
      xPos = xPos + BallSpeed;
+ w( a7 ~- G7 E" I      }
, f- [, }+ [& f- T2 Q1 d   else if (xDir == "left") {$ E- d% ~; n. P$ ]7 r" B. ]0 x( H
      xPos = xPos - BallSpeed;
- r4 r2 f* r. J8 o/ V- J      }
# y* U; @3 M" y' k   else {
& P; W  e$ u3 M# i0 i" b      xPos = xPos;
5 p; j6 E& A* o. w8 Y      }- l5 F. D5 ^' E8 ~- C
   if (yDir == "down") {
5 M' \' \. J  ~$ n! I      yPos = yPos + BallSpeed;
( w" C# S" p0 i! l      }% q  v  Z* D0 H/ j. N
   else if (yDir == "up") {
; {, i: j3 R2 ^# M8 ~8 F      yPos = yPos - BallSpeed;" z1 V" M( `" j6 B' V
      }" M# v$ ^7 a* d/ ^7 w" A8 ^
   else {
' W1 p5 l2 C" Q2 t4 F  k      yPos = yPos;, _& |8 T7 [" U3 }) r
      }
3 e5 Q: u" }5 J3 R: ~3 e6 Q' o3 y   }
  B" E1 G3 e+ ]9 ?9 S8 [( k! Q: S! R9 ]. I; b& M8 _
function hidetext(){9 r6 J1 ]; J' w8 u) d
if (document.all)5 }' X9 ?. P! N) |) l: @
supertext.style.visibility="hidden"$ B& S- X, q, L8 |0 a
else if (document.layers)
5 ]: ?$ b; k  R7 {document.supertext.visibility="hide"% }. R' X' a5 M' F4 w' h
clearTimeout(animatetext)
: E( u+ ^4 K* e; R}0 h+ L6 T# N" |, ^# Q+ y3 `

0 s7 I, F* k  y% D% }. A& M4 Gif (document.all||document.layers){
1 j  w' A  C( B9 W) q; N& D! Jdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
4 S$ S) w9 k7 i$ y, i* Z4 P& hwindow.onload = initializeBall;; E* j" a( G  P) C' k' A
window.onresize = new Function("window.location.reload()");
' V0 ^. R+ |5 p4 n: j' E1 B: K, L5 M}7 F4 {7 k, b. x6 b' c
% ~% |) m$ }5 [: z9 `5 t% v
</script>

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