返回列表 发帖

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

<style type="text/css">/ S+ B2 y- x- i5 d0 F+ s
#supertext {9 \  F5 t+ W, v! P2 V* {# i
position:absolute;7 A2 I% z/ \8 \$ _$ \. o
left:0;
- |3 u$ I1 \9 G; T# _top:0;4 O* _& G  T% Z. p* m
visibility:hide;* f3 W; \; `6 D  }5 c1 L  b
visibility:hidden;
) }  y* Z4 a$ O4 C1 j. u}
8 E" L7 }% n& h* o</style>
  k. @1 K) o/ d/ Z; c<script language="JavaScript1.2">2 {6 J* ~6 }' D
<!-- 改变下的字体的大小。颜色-->
, g; E( ?' v* a3 U6 s- wvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
& M, e% D$ o5 p/ q+ M4 P3 Nvar hidetimer='';7 N7 v1 \5 ~/ k2 h- ?# U
<!-- 改变下的弹跳速度-->; u% }0 c* I) F/ W
var BallSpeed = 20;
4 J6 D, i) Z$ `1 q- o3 lvar contentWidth;" s1 P# g5 y8 g$ u( H
var contentHeight;8 ^, J2 h* q! N. p4 I" [
var maxBallSpeed = 50;
# G4 p7 M$ F; \6 N, \* m$ u+ I4 ?9 Z; v% N, I: f

. P; }  O& S7 p  k; j) D% \+ \var xMax;/ S8 B2 K4 y# L+ _1 _& `
var yMax;7 W( `  ^. F* {: l* U
var xPos = 0;
% a/ c" u3 c' }7 b1 Z' }% f  lvar yPos = 0;
5 f6 }" V5 T# H7 G$ F1 t1 m* S0 I# Ivar xDir = 'right';
/ c9 A* n& [- b4 Mvar yDir = 'down';5 l. j6 U8 I" }2 }5 f
var superballRunning = true;* p  K+ |6 {1 r, z. E2 u
var tempBallSpeed;
' B& B- d) D8 U% @1 A6 u3 L' Gvar currentBallSrc;9 l( h1 m% K' J# h
var newXDir;+ w3 s1 |5 B0 M  i9 i
var newYDir;4 ]0 Q7 |1 H+ b5 w: F8 C4 A
% e& y; @! b( `' k( i5 j
function initializeBall() {. U8 t, T$ e0 P9 x/ H( V, n
   if (document.all) {8 b7 g  y! G% h
      xMax = document.body.clientWidth
" A) s) y# D  H% W$ f      yMax = document.body.clientHeight8 ?$ u1 K9 }6 `3 {, b- ]4 w9 k8 c
      document.all("supertext").style.visibility = "visible";
2 L& w, u9 i( `9 h1 H      contentWidth=supertext.offsetWidth
2 h( W$ n6 r$ x  J$ K      contentHeight=supertext.offsetHeight
" K) R( Z7 M* n* C      }! V  }( w; A7 B; {
   else if (document.layers) {2 m' |9 B( B/ Z+ U
      xMax = window.innerWidth;+ R4 k4 C# k- z: k* E5 h6 Y
      yMax = window.innerHeight;
! o0 A$ x! d% L% u6 D. V7 a* e      contentWidth=document.supertext.document.width) j* {' K9 L& G6 z
      contentHeight=document.supertext.document.height2 E! X5 z  z8 d/ d
      document.layers["supertext"].visibility = "show";6 ?4 n5 b: y$ }, D& T7 {6 {+ q
      }
/ L3 [4 C9 f: f7 A   setTimeout('moveBall()',400);
) c, T) ?' e- U4 l; A: s   if (hidetimer!='')4 |" A4 _' L+ I9 D3 F' J% c& s
   setTimeout("hidetext()",hidetimer)) B# A& Z0 \7 _  s6 |: V4 t
   }
6 \0 r& ?8 {! S6 r) w9 e
  V2 @% c% I7 r4 E) J  ^function moveBall() {% i+ o7 ~5 B/ s
   if (superballRunning == true) {
2 C1 N) z  k" \! E8 k  H5 H& m  n      calculatePosition();! M& U# P" z' @6 }; P3 D
      if (document.all) {$ }9 v+ {% B9 U2 a
         document.all("supertext").style.left = xPos + document.body.scrollLeft;' V/ I4 d0 Q7 g( x
         document.all("supertext").style.top = yPos + document.body.scrollTop;, t; K/ J4 t! w+ D* X
         }0 M; `$ K2 o4 j/ N$ j
      else if (document.layers) {% G5 r; v. m! x  u9 H, e  a
         document.layers["supertext"].left = xPos + pageXOffset;
, Q6 R$ z, D6 D         document.layers["supertext"].top = yPos + pageYOffset;
# V8 W- u& a2 r7 @9 w5 x         }# I5 T8 H, f2 J' @2 R) r* M
      animatetext=setTimeout('moveBall()',20);0 n/ e% Y) b' `) V1 I9 Z6 s& r9 H
      }: f: N8 S) B0 Y% x
   }# y! j) i/ A% C+ C# G# U1 u
# D% U, g  l* R9 A
function calculatePosition() {
* `/ l  E5 H$ }) I! b   if (xDir == "right") {6 U* w, u/ y$ [! g& G; s2 U; Q
      if (xPos > (xMax - contentWidth - BallSpeed)) {
3 M- C% v6 ]' u         xDir = "left";- [# K% d0 L$ O2 j# Q
         }
/ F& J, W6 W; [. V      }
4 b8 G3 U+ ^# k) d9 T6 J4 g: f   else if (xDir == "left") {
7 U- ^$ |) D0 ]* H" d3 S" J      if (xPos < (0 + BallSpeed)) {* C& f  G2 g. {" b, g5 b0 ^4 `
         xDir = "right";
" G. v/ Z% l: i+ S* M         }
+ i  R; D! B$ W6 ]$ n  n+ x      }% ~$ e4 \( e9 ~$ d
   if (yDir == "down") {) B3 e) x- Z6 l" e* L( {
      if (yPos > (yMax - contentHeight - BallSpeed)) {' Q8 Z4 l2 I( w  Q
         yDir = "up";
, E6 w) M0 _7 x0 ]- p         }/ h/ Q1 r: v2 q
      }
( ?) d* C, F& {( v% ^- H7 K: ^2 n   else if (yDir == "up") {
, O  j2 _  P# N2 S& D. C      if (yPos < (0 + BallSpeed)) {
# m7 T  K8 ]9 T+ {) h' ~6 G$ t         yDir = "down";% r/ }, H* R: `! t* Z1 d, U7 r
         }
6 L* D% o& G7 ]4 b      }
  E1 a+ [& |4 ]  ^" F   if (xDir == "right") {  c/ K2 o. x( a$ C# T2 F, \
      xPos = xPos + BallSpeed;: y! V2 W: I) e4 z
      }
7 u% i6 O" b2 F  H( a! h   else if (xDir == "left") {- }7 N. Z; |" j6 G  p
      xPos = xPos - BallSpeed;  L' R' ^5 z: n+ l
      }
' m9 g1 m" N0 p! D7 o9 @" q   else {
# W9 D! A: q# B+ t8 T! {1 P      xPos = xPos;. U: O3 X% D, l- o( Q& O) w
      }' J0 r8 `  t) f7 e% f
   if (yDir == "down") {3 m* I$ F  |  M" E
      yPos = yPos + BallSpeed;
# l! t- n1 e) a7 f      }
! R1 c# x6 O9 K8 o) |   else if (yDir == "up") {, H4 A* X6 {. r: \. w% n. w# _
      yPos = yPos - BallSpeed;* i' [  u6 n% ~$ V$ s. a. N
      }
! R7 L* s6 b6 D* i   else {
- H# ^0 h3 K. y1 V0 B4 o      yPos = yPos;% c: j' {& X4 U# \
      }0 X) `9 L1 D2 {. a
   }$ _) s& U7 r0 m/ S8 @5 k

# m  D9 ^% I3 Y$ zfunction hidetext(){& Z: M) V  ?/ b* v, d
if (document.all)
, E% \8 b  G0 \0 ^supertext.style.visibility="hidden". _7 j- I5 d) T& P% p
else if (document.layers)9 Y! Z, H9 v) j8 A+ w# r
document.supertext.visibility="hide"" }, P+ U* {% R' M% \- }) W
clearTimeout(animatetext)4 [+ W; P3 B6 v. t5 U0 y5 d9 _9 s
}1 }6 m2 T8 M* Q% v- E8 W' j8 b

1 ?) R5 Z# c6 e! h; {1 D# kif (document.all||document.layers){
2 \; l& Q# K0 Zdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
" W4 i/ L2 y. A* lwindow.onload = initializeBall;
) x- I: v* L. l4 {# u2 awindow.onresize = new Function("window.location.reload()");
5 D, G+ E) Z. p; \3 j1 s/ o}
$ U( u! X! E8 Y( \9 D: Z: a  `+ U) N) W, M  x
</script>

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