返回列表 发帖

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

<style type="text/css">
: p0 J) c" E) G+ f/ D#supertext {
' a- W# s) C2 @& d. T8 j( f& Zposition:absolute;
8 l* ^; D# p4 @) aleft:0;+ ?- {; d  H# q3 v
top:0;7 B1 ?- T6 A; ]% z
visibility:hide;
; j* `% V/ u: _/ n. dvisibility:hidden;
% I% {; j: n& `( S. \* {}9 b  @+ A6 ~* F3 V1 v7 _! z
</style>
3 _% C" h5 w' f6 x# c<script language="JavaScript1.2">
% V9 V: c% |( ]7 z8 {4 }) J- H/ I<!-- 改变下的字体的大小。颜色-->
9 h+ b" T: u% q( r3 Jvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% F: k) l$ k$ r( E& Qvar hidetimer='';
) D1 ~, Y2 Z3 h% b<!-- 改变下的弹跳速度-->& X% }0 S' j  x3 S1 R2 i. I
var BallSpeed = 20;
- q7 h6 v3 @* ~3 ]* F! k+ `* A) @var contentWidth;
; \" M) e/ j- t7 p3 g5 Gvar contentHeight;
4 |5 |0 p& @3 f; vvar maxBallSpeed = 50;
: y: b) P0 l. w9 e! p3 P
0 D7 k3 \3 g  f/ U; c/ d3 m2 C- J3 O+ \
var xMax;
# \0 m5 Q" e7 `- ivar yMax;# p& m% D* `: o/ u
var xPos = 0;/ b1 t8 T7 [! O. H, Q9 E0 w9 T
var yPos = 0;. A# j4 F8 G1 g  b0 W. W6 {
var xDir = 'right';7 i9 K% f% a/ C! H3 ~+ W
var yDir = 'down';6 P$ e1 L( j) q( D3 |/ o2 p
var superballRunning = true;4 v5 }9 s# Y7 q* S6 U$ y; h
var tempBallSpeed;' f& _" F4 o8 p( S0 X
var currentBallSrc;
6 d) z. P1 \' ivar newXDir;" A4 M) W9 D- x+ H- p1 c) T
var newYDir;
4 d' S7 b: x5 W7 M4 |( k
. t9 T3 D1 a. y3 A% M$ ufunction initializeBall() {
. g% y, U) w, {6 g  }5 P   if (document.all) {
  ~0 y' W$ S& K& W/ N. }7 {5 z      xMax = document.body.clientWidth$ h# U& ]' u. a1 K& @) [9 }
      yMax = document.body.clientHeight1 X  E$ f2 \8 Y2 O* l; N
      document.all("supertext").style.visibility = "visible";
( G/ x: w" X, V6 L: c      contentWidth=supertext.offsetWidth* Z( ]( {1 V! B- [: @' K
      contentHeight=supertext.offsetHeight
. w- O9 K: x7 s      }: p; X- n6 R9 N
   else if (document.layers) {
% V- `5 A7 p' [& Q8 H. C      xMax = window.innerWidth;
. l+ H. y# o( Q, ~' C: e/ l      yMax = window.innerHeight;
- q; \( N- E3 V, @% Y      contentWidth=document.supertext.document.width; Q7 R, t3 g6 s% [/ H" Y" g5 t8 t
      contentHeight=document.supertext.document.height
) a3 Q4 o: K, g) k% r7 i! {9 H      document.layers["supertext"].visibility = "show";  {* k) c! w' d1 t" w! f; M. y
      }$ z) D: G0 ]; r% G: b5 l; l
   setTimeout('moveBall()',400);/ r& s# {- U8 R- D- N5 k
   if (hidetimer!='')
* g! |8 ]6 ^' @1 h% P   setTimeout("hidetext()",hidetimer)
* I# n6 a) ~7 b: h3 W7 P   }
  W! F4 M$ @, |/ `2 |
& m& k9 d  E8 p: ^. n( @function moveBall() {6 `/ ?7 F% [$ [
   if (superballRunning == true) {
) c$ F# D: e* y; L/ E, R) T      calculatePosition();
) \$ h+ x% S1 Z* p0 s! L3 I: l      if (document.all) {
  T+ E. i$ q# ]& }         document.all("supertext").style.left = xPos + document.body.scrollLeft;
6 D+ Z) t9 u" ?/ \         document.all("supertext").style.top = yPos + document.body.scrollTop;7 m+ o3 M  u/ ]+ e1 g
         }, I' |0 `/ F9 Y+ i
      else if (document.layers) {
' O" B9 Z  D! P0 f         document.layers["supertext"].left = xPos + pageXOffset;
; G+ X6 a  Y: a7 l6 s' `         document.layers["supertext"].top = yPos + pageYOffset;
  }6 E8 P' D4 {7 d& M- u. J         }
8 t" H7 M8 A4 D1 Z; T      animatetext=setTimeout('moveBall()',20);8 x5 d3 a8 {5 f! c4 \9 ~1 m
      }
: `  k" P' _0 s5 ^7 T   }
+ Z: P6 J- S+ u$ i! j9 U, L- f/ {! N/ x4 P
function calculatePosition() {
6 Q3 R7 y+ }: s   if (xDir == "right") {' z* g+ w. d+ W7 [/ L5 v
      if (xPos > (xMax - contentWidth - BallSpeed)) {
( c9 K2 |% Y( Z+ _         xDir = "left";1 k6 Z' V/ x" {* V7 m. ?" @" T
         }
: e8 g* h7 u3 O' R; V9 i8 ?      }
2 j: Y. ]& @" ^( i   else if (xDir == "left") {/ i( P  a* }1 y# j
      if (xPos < (0 + BallSpeed)) {
) m6 [+ m7 q% R/ L8 m, K         xDir = "right";
1 N7 W- j4 R( U, e/ q$ O8 |         }
/ j9 r6 y  n% L0 \      }
  Z5 R9 u9 l9 @   if (yDir == "down") {) r6 O* M; n+ [+ r
      if (yPos > (yMax - contentHeight - BallSpeed)) {  Y" h7 y3 X9 m+ g6 e/ E+ Y8 M( |
         yDir = "up";( i: A4 e9 j% {* I( f
         }
) V% r- q' c2 Y! c& h; u& j2 v      }
/ Y0 ^1 t3 N6 }. h4 I- h1 q   else if (yDir == "up") {/ ^( j' o4 s7 O8 L
      if (yPos < (0 + BallSpeed)) {
+ }* E2 [( ?. y% P; n8 L1 g         yDir = "down";
: N- W7 ~, F0 p- h, K# `8 S         }
9 |9 e2 k# y2 \1 z+ B7 P6 V      }
3 t% \7 k) C3 d7 W: B   if (xDir == "right") {5 V! m* g. P2 Y" K3 B
      xPos = xPos + BallSpeed;; i  ?4 L" U/ c: D* {& q3 E
      }
, O/ D! \- B2 y9 r2 Z+ V   else if (xDir == "left") {
$ w7 b3 m5 m. u( o2 v      xPos = xPos - BallSpeed;
- ?$ {4 d8 `& J. O2 p      }: ~' R% X" L, L3 g3 ]1 g# `9 A: O/ Y
   else {* N3 M  l: @* ^% F- s: E- S
      xPos = xPos;
- K5 F) R* M5 R" W1 m( R      }
( ?1 p9 X) W3 F& Q. e, P   if (yDir == "down") {1 e1 ~. \7 ?+ r8 J
      yPos = yPos + BallSpeed;
( _9 k9 g( A$ Y0 b+ h9 u      }
5 C6 n1 w- U9 x# [   else if (yDir == "up") {
* J$ [8 k* V6 J/ u      yPos = yPos - BallSpeed;/ Q+ k# o3 W! _+ x+ s5 D: V+ `
      }  P* j1 U' I% h0 C. J
   else {
( H6 n/ k; V. R. E& ^3 c& E      yPos = yPos;, m, n4 l& o6 L  L4 U0 @' R
      }/ Y# V+ m( I5 M& D4 B
   }
0 \3 N( r  S( o4 o: l- t& q( \
$ c$ [$ J6 W3 ~2 W# Y$ }5 Tfunction hidetext(){
/ W( ?3 s9 i3 [- c1 bif (document.all)
# _+ s7 N' q; {6 Y5 f0 Wsupertext.style.visibility="hidden"/ p# ^2 x; t' N. c3 s& y4 p
else if (document.layers)6 X- a1 \& V+ r3 ?. H
document.supertext.visibility="hide"3 w/ S% f' o6 X; s: h
clearTimeout(animatetext)- Y6 O( t4 b" f9 s; Y, H
}5 e8 i$ t+ m4 T) D" n# Q4 e
* f$ ~  @7 `( Z+ Y
if (document.all||document.layers){4 w* g; q; @5 i2 D9 `
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 {, n' j' K, i; W1 P6 kwindow.onload = initializeBall;
- r# z/ t5 F' [% q2 A/ X8 [window.onresize = new Function("window.location.reload()");
5 I& y; r4 H1 Y* R) [; O}
. w) K1 }: X" s2 b
8 j# O# a$ @' W) P</script>

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