返回列表 发帖

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

<style type="text/css">
: M* w2 y1 z) F# C  {3 u$ w7 U#supertext {
" K* t5 g) n5 t- J/ u0 z% y4 G; ?) Kposition:absolute;2 q4 E/ N/ q" }0 g, L* N- G- ~3 z2 j
left:0;
$ F7 z# k% v1 C; Y- v" |8 @top:0;
2 `  J$ Q+ K- |% r8 j4 S2 y3 ?( j( P. tvisibility:hide;9 y8 |" n9 @# `( J5 z5 O
visibility:hidden;7 L2 C/ q+ A$ l) d, \$ h) K8 D
}
' w6 h0 Y- i" x4 y7 v( e</style>
' J4 D% o0 ^" s) s<script language="JavaScript1.2">" R- m1 y0 r( V( D6 W9 M5 M
<!-- 改变下的字体的大小。颜色-->
/ A9 t. ^7 R. {% S" j  J9 }var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
* ?4 }% o, ?& |6 u- ^& d' {var hidetimer='';, B% @* a$ g) n! f6 d8 ?9 `
<!-- 改变下的弹跳速度--># i" H- v2 B7 q, D
var BallSpeed = 20;, k5 f8 ?# v- r: v. |
var contentWidth;4 V2 S% G# [/ n+ h( r. A. X& ~* p! d
var contentHeight;
& ~# b0 M0 K) X* B' T/ a5 @% zvar maxBallSpeed = 50;3 n0 o, H+ C$ ~* T8 |$ _* e, h
1 `" k& t: Y% x$ \, t8 c8 F
9 N5 k7 Z, X& s! |: f4 B, A
var xMax;
1 \5 m- B, P' w; t# ~( ]! o  Rvar yMax;0 T) ~8 m% F  v' ]; I7 x2 Y
var xPos = 0;' ?& G9 L( T5 }/ W1 H& O  D4 `% U( B
var yPos = 0;1 q; P& ?; |4 n, \% T3 T& d9 z
var xDir = 'right';6 E  a4 Y! Z3 s  b; l9 a
var yDir = 'down';9 a# s8 U' a5 R$ K0 y! Q1 s2 p# i
var superballRunning = true;9 B" r9 ]1 j$ D5 t3 O. C# U) u
var tempBallSpeed;2 z( _, D* S. ?8 n- b$ @& h
var currentBallSrc;: X7 [0 X. F# s
var newXDir;8 w7 R  o# A1 T0 u4 O  W0 H
var newYDir;
+ ]- j( P" z$ {% _- C* u
: r7 Z/ B) W! pfunction initializeBall() {+ I; G( x( Q  X$ i: e
   if (document.all) {
, G+ z8 |' R! c4 _9 H9 `7 c      xMax = document.body.clientWidth6 h$ b- c& Y$ f
      yMax = document.body.clientHeight" V2 I8 D9 m- G# Q6 n; s# ]- q) l0 ~
      document.all("supertext").style.visibility = "visible";/ W. d( F: w  `2 Z
      contentWidth=supertext.offsetWidth6 c) n5 @% D& }! D1 f! }/ k5 m) U
      contentHeight=supertext.offsetHeight
3 A$ y3 I, K; J' S1 [# L; q  ?) x& P      }3 a) e; K  Z; I7 r* C
   else if (document.layers) {& N  d2 ]  t) W0 R2 Y
      xMax = window.innerWidth;9 r6 }- D: R; }5 L1 V, F; O. ]
      yMax = window.innerHeight;
9 g- U" I) g' F* L1 D9 s  K      contentWidth=document.supertext.document.width
6 _& R: n. `, E* u* K      contentHeight=document.supertext.document.height/ b7 f5 X7 J3 f
      document.layers["supertext"].visibility = "show";( v! D! g, \+ ]$ k) j
      }7 W# d, z# v% M2 m0 ]
   setTimeout('moveBall()',400);- y7 t  M9 b9 e" W2 V$ p
   if (hidetimer!='')- ?" y; ^6 T9 i. D$ C, |
   setTimeout("hidetext()",hidetimer)
5 a( ~& q7 a0 t8 m8 {, g   }
  `; ]$ P9 Y' L, t0 V
# K+ ^- f6 r4 G  `& y6 afunction moveBall() {
9 t1 \& K- e: T& d   if (superballRunning == true) {
2 W4 T  R; g4 p3 \& J7 V8 z" s      calculatePosition();9 ?# J  X2 l# r8 i: P# ]
      if (document.all) {
; A' s" |9 P6 ?9 C, e# p$ U         document.all("supertext").style.left = xPos + document.body.scrollLeft;
; G: {$ r( j1 W5 M6 k& l, |         document.all("supertext").style.top = yPos + document.body.scrollTop;
  E- s! G/ B* ]4 w( P! x         }
& Y" d) `' e# R      else if (document.layers) {
2 i2 ^% W9 C7 ?$ C' t         document.layers["supertext"].left = xPos + pageXOffset;; i2 C+ B2 @. O+ F: v; `. V+ b
         document.layers["supertext"].top = yPos + pageYOffset;
- ]! G: l+ F* r2 ]         }" {  k* f( Q! W8 M+ j, R( m
      animatetext=setTimeout('moveBall()',20);
% n; w! F' X- G/ ?  P% J      }4 u4 z8 m5 |; L; D8 p  _7 h
   }: {% x  F& H: x. K: g

% W/ p, J8 C4 w, ^8 J! s2 Sfunction calculatePosition() {0 c  @8 d2 \/ @
   if (xDir == "right") {
7 k) p' e# s7 v+ ]      if (xPos > (xMax - contentWidth - BallSpeed)) {
9 {& R; {5 X  Y, E/ Q         xDir = "left";
! ~' i! W; m1 ?         }
; z# J& R5 T+ {9 k: |, o      }
, s  t' s' e5 H: n   else if (xDir == "left") {' {  R* H$ O- R
      if (xPos < (0 + BallSpeed)) {9 [2 Q, Y: k' N
         xDir = "right";+ }4 I  g7 I/ H( c# h
         }
: M7 J( `# J' {: n  |6 |      }' Z" l# _' G" Y; Y' K
   if (yDir == "down") {
' ^( u3 }6 x+ k9 }  V/ Q! x9 t      if (yPos > (yMax - contentHeight - BallSpeed)) {; d9 t: H/ {2 g
         yDir = "up";2 E5 c, ?8 L' y+ d0 S- w3 E
         }
5 v5 D, a, n; p' i; d. B      }6 L: m# o$ F' G
   else if (yDir == "up") {9 L5 t" G, w# K0 Q! L" |
      if (yPos < (0 + BallSpeed)) {
- p( Q- t2 d# r0 z+ m         yDir = "down";
% r* L8 [& r  Z7 {         }  d, `* {7 M  n# o0 N. T1 U
      }
  D7 u8 V9 k3 d4 A9 Z/ V   if (xDir == "right") {
  ?+ \. @: t7 f3 q  c1 q) j      xPos = xPos + BallSpeed;/ G( o) E4 m# o4 }9 v- _
      }
6 S$ ]! l/ D6 B   else if (xDir == "left") {# W! n- ^5 n  L& v9 W8 \3 {# F- C7 {
      xPos = xPos - BallSpeed;3 r7 O9 V& P6 o- a
      }
" p2 Q8 }+ D: P   else {. u6 e* \/ y6 ~; t* \
      xPos = xPos;
$ O1 d( S! `' i* O9 @& m      }; L8 l1 J1 Z1 n$ q; W5 V
   if (yDir == "down") {
! V. |7 g& j% K1 L# I      yPos = yPos + BallSpeed;
! @5 j* |! J0 o      }: V7 x  `4 I9 v$ G7 `8 Z
   else if (yDir == "up") {
& T3 d+ u. v0 X" Z" U& F, s      yPos = yPos - BallSpeed;
7 E+ s( ]0 x* l4 S+ }      }: w9 k$ j+ d6 `
   else {
& x2 R5 I, F3 P8 w2 u2 \1 V      yPos = yPos;
. T; S  p1 ]+ y& c+ ^      }  [& {9 C) l, S+ o1 {
   }
& Q8 g% D1 \$ F& y# Y5 _5 G6 n4 U) w5 J: ?) j! v- K
function hidetext(){
  Q3 C% o4 V  L3 a4 O; u( Hif (document.all)/ u# h# |; R8 G
supertext.style.visibility="hidden"  \7 a2 P: v) F- G4 O
else if (document.layers)
1 A" [# X7 |/ F; f, i9 X. I. xdocument.supertext.visibility="hide"( j$ c7 N2 T1 y, m
clearTimeout(animatetext)$ _; A5 d# x! _
}1 M) \0 [4 h$ X4 ]& \* G

# F# N4 Z6 h6 o3 P8 V5 bif (document.all||document.layers){! h+ z7 E: a! l; x. `6 H. r. a& G
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 @- M& |8 P8 a' r/ C1 jwindow.onload = initializeBall;9 x+ x' v- R# r! i* a4 K% ?
window.onresize = new Function("window.location.reload()");$ h6 Y+ \1 H) I0 @5 E
}/ ?3 w- z7 _( O- s2 X

; }6 |- p! J5 D: [</script>

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