返回列表 发帖

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

<style type="text/css">
5 `% \; L; h  K; ?/ |: B#supertext {
9 Y) b& J! a+ |position:absolute;
* h, @: X) x; C7 e0 ~% ~left:0;
0 [1 h! z3 O8 I& ltop:0;- I9 x4 L; M3 i0 w8 m8 B
visibility:hide;
5 i; Y; F4 Y! l$ G7 w- pvisibility:hidden;
/ Z* r* `4 W  x) D* s" }/ w  T}) h- T& G/ U+ n2 V- D
</style>" u1 \" `$ y6 ?
<script language="JavaScript1.2">
0 ~  |0 h1 ?6 H: H<!-- 改变下的字体的大小。颜色-->
  m7 a" x! I! W4 ?7 D, T: lvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
) G' G5 a2 S9 L( jvar hidetimer='';* j+ Y  o9 T  J  V7 k/ g
<!-- 改变下的弹跳速度-->; c$ C( c0 m  }' M
var BallSpeed = 20;! }3 W" V' A) x& z* t- Q" b
var contentWidth;; @& q8 W) x: d
var contentHeight;
& c9 [9 O0 X# w: z$ b- _var maxBallSpeed = 50;* I2 _: d2 K7 l) r% R$ t" Z; ?
0 j9 \" x; a1 h1 a( ~& ~
. N3 v/ Y, A: E+ y, k4 A' r
var xMax;2 Y7 ]! i# d) f7 {0 @
var yMax;& H$ q# S6 c7 B* b' c4 X, m
var xPos = 0;
+ V+ X6 y8 Y" H. g" B  f7 P4 c0 cvar yPos = 0;
" ?9 E( O8 d+ j- Y$ a: m1 Uvar xDir = 'right';# P7 z4 F5 b% G+ l; b9 J
var yDir = 'down';
' J, I2 H. T3 L! a, o! O- N+ |var superballRunning = true;
6 q5 W/ d  k8 Uvar tempBallSpeed;5 g8 Q  N( }2 `  _
var currentBallSrc;
: ?8 o, C6 w2 _7 }5 Svar newXDir;# `" m+ y  Y' b+ }2 `- X. P
var newYDir;; t4 ^2 X8 j  m! U5 V1 x, F
) S$ a* e. e# y9 g: m# a" X6 F
function initializeBall() {
1 z! H7 D; H* n' L, [   if (document.all) {
. t2 H! U- E( _1 U      xMax = document.body.clientWidth# X, }; p- ?/ M; u1 s5 M
      yMax = document.body.clientHeight9 v0 b4 t0 {9 X  `1 `4 [
      document.all("supertext").style.visibility = "visible";
- |% `) P" U( [4 O      contentWidth=supertext.offsetWidth8 u3 r( G/ [; W8 v' F  e
      contentHeight=supertext.offsetHeight+ E, B7 J! Y, e9 ~  _. Z- t0 m
      }9 B% |7 J' k/ {# E6 K" B
   else if (document.layers) {
, n) d% n& O. j1 A& _/ X      xMax = window.innerWidth;$ l* O! g  m: h# {2 y7 u4 t3 B
      yMax = window.innerHeight;  f- n  B9 ]# @& O5 H6 n0 K
      contentWidth=document.supertext.document.width
0 i& X- S1 |1 S8 X      contentHeight=document.supertext.document.height' F( }0 a9 w9 h" r4 Q$ P
      document.layers["supertext"].visibility = "show";
0 e1 c- N# ~, X+ O& h      }
% G6 k0 h$ m- p1 V3 ~( r4 [  N   setTimeout('moveBall()',400);, y0 p5 ^4 H6 X3 E9 j0 Y' J0 n
   if (hidetimer!='')
1 i2 |) G+ a- E4 L7 x( i2 F) N   setTimeout("hidetext()",hidetimer)/ u8 M, u3 I1 y3 Y; N  g1 O: N8 h
   }! |" e7 ~( l# b1 h5 i0 N# C
- Z- O3 K( Q% f5 h: t! W& u
function moveBall() {7 T5 ^  a& \4 q; i
   if (superballRunning == true) {
0 L! ^8 f- `" m. I% A      calculatePosition();2 u' W+ w. B" l8 M/ x/ a
      if (document.all) {
2 N% ~% C9 i% d# _3 Z0 ^         document.all("supertext").style.left = xPos + document.body.scrollLeft;
. e( l7 s6 F4 [% t/ X+ a! `5 w         document.all("supertext").style.top = yPos + document.body.scrollTop;- ~1 b0 n: e. f% M- u3 P0 x" y* Z
         }
5 X+ @5 [4 |* |# |: |; W$ \      else if (document.layers) {
* y$ N7 P7 m$ v  T1 G' n9 r4 a         document.layers["supertext"].left = xPos + pageXOffset;- K$ X% L; O' }# N5 _9 x
         document.layers["supertext"].top = yPos + pageYOffset;
2 n+ J( K( r7 ?! v         }  n/ o3 r3 y* F" _
      animatetext=setTimeout('moveBall()',20);& S" V% Y2 q& f/ ]
      }, o+ A) j! }4 W
   }3 L3 j/ G9 H8 l7 Z

6 B. ^" x/ z" A9 J# vfunction calculatePosition() {" z, \1 s2 K. C: L6 i  |7 m
   if (xDir == "right") {
) H4 _% ^% Y9 `      if (xPos > (xMax - contentWidth - BallSpeed)) {
; b2 ^# r8 A( w9 b         xDir = "left";
9 S* |" c7 J* i. c         }
# v4 n* P# O. _( u" J. L4 z      }# S) H. f7 l) \9 y: P5 y- }; S
   else if (xDir == "left") {
& S. {! L+ v% p      if (xPos < (0 + BallSpeed)) {
( G2 T4 z$ [+ ]( h         xDir = "right";
& h4 b  E2 k/ e+ r& a) n% S         }
+ w! e! Q/ x1 i      }
9 a) E( L" `/ c- x" Y   if (yDir == "down") {/ ^' h, T* i* R( P+ g8 Z8 M# O
      if (yPos > (yMax - contentHeight - BallSpeed)) {* X) z  U. p  N; p
         yDir = "up";
, S  C  |2 {4 ]! ^5 ]0 C/ }! o+ N) T- g         }: L# y9 q9 n3 ]: h, `
      }
% @" ?2 p+ `6 [' Y  E- c   else if (yDir == "up") {
8 A, }. \( ?- R! Z$ w      if (yPos < (0 + BallSpeed)) {
2 u$ t3 W4 ]( y* p         yDir = "down";
/ n, F4 @) ?" z! c/ G         }& {; O% _5 ^/ b3 W. t6 ?- k9 p& N$ l
      }
5 a$ a' b  j0 @   if (xDir == "right") {
5 L/ m- K; g6 {$ e, u      xPos = xPos + BallSpeed;1 W4 h! n) j* V, y2 x
      }/ m+ p- P- d* {' |
   else if (xDir == "left") {. F& e* |* A9 t! H) Q
      xPos = xPos - BallSpeed;% l; {( A# T, S' _
      }, Z& y; r6 c, c$ k! B
   else {9 \9 z0 Y# T( p) n8 I( o8 j* I1 U  I
      xPos = xPos;8 v) i2 X' t  p% \2 R8 y" Q9 b
      }; j. h6 Y3 t0 f) ^  q& P( j7 P! C, |
   if (yDir == "down") {
9 Q7 E8 f, m2 t- \# Y. F  C      yPos = yPos + BallSpeed;/ \3 A- R. k9 M# Q, Q
      }9 T4 u0 s$ S+ S; U! v4 i. \4 m
   else if (yDir == "up") {
, {& k$ r6 a0 _! x" q9 o      yPos = yPos - BallSpeed;; V( _' T, F! h# z6 _. `& n
      }& n; ?# y) r: {, J" h: O$ c; K
   else {* e" u  r, I) F# m2 ^" S, Q
      yPos = yPos;* v- W  b0 `" d9 b1 B
      }: Y5 H& C8 Z' l4 U
   }
: O/ k) g1 D: K- c$ U4 k& f* P4 e/ ]0 Q# s! v) ~+ H
function hidetext(){8 P; ~9 m! O8 a9 D7 z
if (document.all)9 J& q) e' e- i0 u
supertext.style.visibility="hidden"
( L; O5 G2 t/ i( _else if (document.layers)
& g( q& Z7 B+ G' z  m7 Q1 ^% jdocument.supertext.visibility="hide"- b/ `' l9 x* o$ j
clearTimeout(animatetext)
# z- R7 K3 ^- L# R1 H3 P( q}
9 \4 X3 H7 `2 E6 E$ K! F. ]* x2 _0 u4 V9 n. [5 k; {' m, G" M4 h
if (document.all||document.layers){
; s- g# w+ |: s; V- Sdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
' K4 A/ _+ _: [2 b' r% |; d% uwindow.onload = initializeBall;
" z. S- Y  _* Q* P0 |window.onresize = new Function("window.location.reload()");
: g! Q5 {" f# J3 Q) y% @}- V- q" E0 z! l; j  _

. j; e- L& u) W1 z9 m1 X; ~" z/ b</script>

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