返回列表 发帖

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

<style type="text/css">, Z6 s6 `: t+ [. Y
#supertext {
, Z; I- ~9 Q8 ^1 c3 |position:absolute;. i( s- J; ^) x6 A
left:0;
- j( e: S  l  R! S8 `" s$ y; vtop:0;# v/ _5 R8 n0 V6 S* {6 J
visibility:hide;$ k2 b# ]* F$ d1 V8 ?
visibility:hidden;
3 l) R6 _: Y, I3 g! H+ Y5 @2 X}
+ U: L5 k8 ]" x; Z& Q% ~6 ~0 N* |0 ?</style>1 W! H$ g' H0 P$ Z" A
<script language="JavaScript1.2">
$ ~; M8 C" t7 u; d% M: F4 x<!-- 改变下的字体的大小。颜色-->
9 T5 b" m3 A$ ~  l0 rvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
2 _. P. ^( i' D3 }% R0 Kvar hidetimer='';
, {' @; m4 m/ U) Y  I<!-- 改变下的弹跳速度-->
  c9 @8 s4 D( v- h* q8 B* C( }var BallSpeed = 20;
$ Y# t( S& j3 p1 Ivar contentWidth;9 Z$ i7 k, }+ A$ @: C6 |
var contentHeight;! Z$ V; @8 J, c$ g
var maxBallSpeed = 50;
9 \! v+ u' u/ ~  @- ?
, F. V' L6 C3 u! u" v  ]: ]7 |
: X0 K9 Y8 O7 H$ _6 x% yvar xMax;
9 v5 r0 `  }# {& S- U  Ovar yMax;
! W+ c, {& W6 ^0 Y, Y0 F$ Y9 O' p& |9 fvar xPos = 0;
% Y# d' {; Q+ ~# Qvar yPos = 0;, U% Y. U# P0 T* m5 l) Y: {3 ?3 b
var xDir = 'right';9 r- D- b6 _8 \! A+ t
var yDir = 'down';  a. y2 P; J9 D/ E8 L$ T
var superballRunning = true;
5 W$ A- `* r4 m8 [# I, Lvar tempBallSpeed;, Q) b! o, L9 V6 q
var currentBallSrc;) E1 z' j- \( I; I+ X0 j& F) B# u
var newXDir;
+ x' p! y4 v* W; v: t; Wvar newYDir;
+ j5 t+ Y+ D! M. N; Q" F! y$ k' e8 Z; L
function initializeBall() {. L' N7 U8 `1 u
   if (document.all) {
' N1 Y# |$ \$ {0 l      xMax = document.body.clientWidth1 _% g3 F. r5 p$ O( x
      yMax = document.body.clientHeight  O7 h9 S4 n; E; ]- ^: Q
      document.all("supertext").style.visibility = "visible";* T. G4 E5 v7 c4 O$ y4 e
      contentWidth=supertext.offsetWidth5 e5 F  Y, k0 @. G& F
      contentHeight=supertext.offsetHeight
4 f. I3 k" F# H# U! y8 P" r5 L      }  t: f$ G' R. v( g4 x3 v
   else if (document.layers) {
# [3 _- n6 O) |, d$ C" X      xMax = window.innerWidth;
) P# E6 A4 D0 V1 w" {& E      yMax = window.innerHeight;
/ u/ m, m5 B5 m; @8 c) v      contentWidth=document.supertext.document.width" U' @/ L2 y6 {
      contentHeight=document.supertext.document.height
, Z  g8 i  \: n0 @* f' f. p, Y      document.layers["supertext"].visibility = "show";
4 G& B$ A1 K+ X* ?/ l      }
7 T7 L$ p) T. f3 ^   setTimeout('moveBall()',400);7 c( s$ k+ N- [- t! A: @
   if (hidetimer!=''): S- B; y! ?" z9 w
   setTimeout("hidetext()",hidetimer)) e+ r" o6 K0 ~
   }$ c+ N0 B% M+ m& k3 H

- C& W& G7 \7 v5 yfunction moveBall() {
0 |0 F  e+ |! ~   if (superballRunning == true) {
+ E  L$ u( y! ~7 s9 D      calculatePosition();. }, U% t( p8 H
      if (document.all) {9 J$ U* ?1 y7 g! r
         document.all("supertext").style.left = xPos + document.body.scrollLeft;6 Y( p9 G- Z% I) w
         document.all("supertext").style.top = yPos + document.body.scrollTop;
( B+ g0 C: b+ J         }
8 c* j" F6 B: B2 b      else if (document.layers) {
' U) m( Z% d6 ~  D         document.layers["supertext"].left = xPos + pageXOffset;
5 Q2 @8 n# P, `' M8 E         document.layers["supertext"].top = yPos + pageYOffset;5 ~# Y& ?3 A) r4 `. ~; s1 [
         }
$ Q, ], n. w: E) h, C& @      animatetext=setTimeout('moveBall()',20);6 ~( E4 D0 z& b# g
      }3 ]8 O4 C5 F6 R/ q
   }' @( U2 ?% F8 T4 G
' U: s7 o: S7 ~
function calculatePosition() {
  i$ J8 |1 j- ]% R) j0 n% t   if (xDir == "right") {- P. m9 {5 k9 r) E- W( d
      if (xPos > (xMax - contentWidth - BallSpeed)) {, a& ]/ u: A. q2 h/ P
         xDir = "left";# O& x$ a$ z- B6 y3 N9 G* w3 w
         }
+ l* j/ a7 _+ P/ o      }+ v: @' \6 o. e6 F6 M; f
   else if (xDir == "left") {( A9 s% b! d! o: o+ R' L
      if (xPos < (0 + BallSpeed)) {
3 ?7 Q5 Z: x+ T7 a6 w& d) o4 ?  }         xDir = "right";  [; D8 w8 ^2 _' V/ o6 _* ?
         }- {8 y% O: E' u2 t2 J* l; M. o
      }, P  f" v, A0 Q& b4 q" G
   if (yDir == "down") {3 ]* q& x& C& a
      if (yPos > (yMax - contentHeight - BallSpeed)) {
# o. n7 O6 D' T0 P         yDir = "up";3 ]5 n$ H4 D- k
         }
$ }' }" K$ P# v5 ~! x0 v" ]      }+ G. Z$ L" x3 A: d) I  m
   else if (yDir == "up") {
0 _* g8 l, G" m  {0 n3 K: y      if (yPos < (0 + BallSpeed)) {6 C3 |9 q. _- X8 V
         yDir = "down";
% T7 A7 n' p' n- Q2 A         }
! Q4 E5 L- N1 p- h' g+ f1 |      }
5 T( \. B* s: ?0 Y1 B   if (xDir == "right") {
5 b8 n9 v$ U, W# ]# [4 Y9 X      xPos = xPos + BallSpeed;
- U! c' G% B. I. s5 G/ x      }8 f& P# Y' A! A9 a3 u
   else if (xDir == "left") {
  m0 f( t. g4 E2 R      xPos = xPos - BallSpeed;
9 l- n% T- }. e0 i( ?5 R      }
. q; `) r! `6 C   else {
9 {7 A9 J6 n" b( Q' R( _      xPos = xPos;
& F2 ?. E* t! A  w0 e# }$ u      }
" b/ x1 Q  K, E3 A( c* T   if (yDir == "down") {* o% ^) v" K; X1 `3 J
      yPos = yPos + BallSpeed;
- s$ y0 C9 T" |$ N$ Y      }
, j" d. [* l+ v   else if (yDir == "up") {/ A5 t( m* a& V9 d$ `/ W
      yPos = yPos - BallSpeed;. n. Q( S7 y( I
      }; D. ~0 h6 A9 ~& r
   else {; {7 G; r2 D( ^! V7 V
      yPos = yPos;
# E1 H) w- U( T7 W+ d9 X      }
7 J0 ^4 w, H0 D! `$ `- j   }
0 ^8 u6 x8 ]+ Q$ l, z6 C5 r) P5 v2 E& n, x
function hidetext(){# n8 h+ Y0 L( v8 E
if (document.all)
7 p! [! `" S: hsupertext.style.visibility="hidden"& w+ \) L+ O+ {& v0 `8 O
else if (document.layers), O8 ^. u0 b7 r: e3 i5 Y" B7 D
document.supertext.visibility="hide"0 [2 ?# B. M( b8 J
clearTimeout(animatetext)+ M; ?4 p# y8 |: V" L
}
7 j/ O9 e8 w* |$ v; K9 g+ W$ w$ N- w( y
if (document.all||document.layers){
/ V+ g  t  u  Z' vdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')  Y( y' F, X# V; O) p$ F% C
window.onload = initializeBall;7 T: Q; x+ `% S  ~( S5 G' s! \7 }: d( W
window.onresize = new Function("window.location.reload()");9 @5 m+ r4 J6 n+ X
}9 S, E3 y" e" y1 S2 ^: H7 o

4 R8 ^: a+ r+ V0 Q</script>

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