返回列表 发帖

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

<style type="text/css">$ ]: w$ \. M7 r: U
#supertext {; j2 [, f5 Y4 ~; ?
position:absolute;6 j) G) m! P  S5 l0 K
left:0;$ f" G- M5 \# W# Y9 _
top:0;8 T) @! b1 e5 T4 B9 r& b
visibility:hide;9 R" J! P* M( U- _  z$ x# ]' G4 D# N
visibility:hidden;
* U& n( h. {( F; C) N}
9 B: B- W* u; c& v5 X" G0 t</style>
5 i3 H' W) j& r( z  z' P5 Z<script language="JavaScript1.2">
+ ]3 Z$ @1 p/ p2 k  M<!-- 改变下的字体的大小。颜色-->/ D. b( w4 a' t& r5 ?
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
. w3 F/ ^4 f/ I3 Tvar hidetimer='';
/ ~. r# K- R5 m5 Q( D<!-- 改变下的弹跳速度-->
' H" N0 |4 ?# E! M4 d: C8 a/ Gvar BallSpeed = 20;7 Q6 B% {( C; g& m9 L. Z
var contentWidth;
) S& w$ U2 u  f& n' i8 V- `var contentHeight;7 l; {; o5 O9 q  \& d
var maxBallSpeed = 50;
* w0 i0 X, S6 ^) j4 [
; W8 s, Q; k0 Z' f0 |7 |$ y) {0 P- @9 Q
var xMax;
1 D0 M9 p/ E+ p' T3 |var yMax;
9 b* m7 ~, d" T, L4 vvar xPos = 0;
. ?3 v# j6 g% {- A0 avar yPos = 0;; r  H. h' j7 ?5 N* Y
var xDir = 'right';
7 K; }: A) M; Y' Ivar yDir = 'down';* V! f! F# B+ g) Q
var superballRunning = true;) @. ?* g$ y" k
var tempBallSpeed;
6 I! {5 q9 |6 p  {4 [var currentBallSrc;3 E0 O7 s7 l! ~' ]  X% h
var newXDir;
) g8 u+ O1 v6 E" j# N. x$ gvar newYDir;
0 L; L% i3 u8 Q* t( L8 O1 i0 O* ?1 ^' I
function initializeBall() {1 l" m* A5 L, S7 R
   if (document.all) {
, D& ?/ n* `& e, D3 A7 q( l# o      xMax = document.body.clientWidth
8 Z" n3 X' A! z0 G# M8 q* S      yMax = document.body.clientHeight! m, I9 }6 p1 `
      document.all("supertext").style.visibility = "visible";
# B, o* K/ X# o) \      contentWidth=supertext.offsetWidth" L  Y2 o' s% @
      contentHeight=supertext.offsetHeight
3 u8 u4 _! s/ o  u$ l      }6 T+ f* d  l, z2 e$ J8 a4 J+ K& o
   else if (document.layers) {
; G7 m& h  V/ _      xMax = window.innerWidth;7 x! D+ L8 G! Z1 o: R
      yMax = window.innerHeight;
% c, y: S# Y) _1 d4 @      contentWidth=document.supertext.document.width* }+ v# ]+ T* G5 }6 g6 G
      contentHeight=document.supertext.document.height' K8 {9 W9 \7 I) j% e% K
      document.layers["supertext"].visibility = "show";( Y, C) t3 T! A2 O
      }2 M0 T' ?0 o5 O' W
   setTimeout('moveBall()',400);
/ h; _  Y: }/ d) i  C$ Z+ q   if (hidetimer!='')
8 q. f0 p$ f) l( X9 O   setTimeout("hidetext()",hidetimer)$ {7 N9 H% `, T
   }
: L; j- |/ |0 N3 r
, f& D5 Q0 T# e7 ~. D* F3 ]+ Nfunction moveBall() {
/ x' A- f! R1 O) \, J   if (superballRunning == true) {
- _; u, f4 S" t2 m      calculatePosition();
# ^9 W& w# w- O" Z# ^% p( m      if (document.all) {$ ?% ^; f8 A' h
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
5 `7 }3 o' f+ ~# C0 E% F         document.all("supertext").style.top = yPos + document.body.scrollTop;
3 W" ]7 C& |! h9 M         }
% X$ w" [& G- |7 y      else if (document.layers) {
+ F2 s; @6 t9 q         document.layers["supertext"].left = xPos + pageXOffset;" Q# s. [2 R% l4 D
         document.layers["supertext"].top = yPos + pageYOffset;$ F. h, U: ]& z( h$ b5 R
         }
2 w- {* ~' |) K; F/ M, Q      animatetext=setTimeout('moveBall()',20);
* q6 m- ?3 M& N) l5 I: X      }
- c* Y6 p* Y8 a! j9 Q: t   }' R/ U; O+ c- p: _5 r; Z' C0 C4 Y

" B5 A$ Q* ~4 M" \, k3 ~6 \function calculatePosition() {
& Y" v/ B. [) [5 w   if (xDir == "right") {
9 Y  j1 G$ H* S# l7 `      if (xPos > (xMax - contentWidth - BallSpeed)) {0 M3 i7 O& K' @0 ^: J( L) l. N; s
         xDir = "left";
- z# f% p4 ^/ W9 D, F! u         }# |( L# Z! r! N  k3 O
      }
0 @% l& V# U% f1 O( C   else if (xDir == "left") {
& M8 j, S0 t5 J9 `& W      if (xPos < (0 + BallSpeed)) {
: t8 A! ]7 D' L- n0 f         xDir = "right";
8 o5 V; F3 z3 \         }. Q+ |5 ~$ m$ _% I3 _& k7 a
      }
9 {! B: }/ Y' y   if (yDir == "down") {! j7 l" U- u2 q: _* f6 M# p6 Q7 D8 f
      if (yPos > (yMax - contentHeight - BallSpeed)) {  E- |1 d+ v- ~9 Y+ O
         yDir = "up";
6 D" D8 [) H" L. t         }
6 l5 j- L# [0 x      }& J2 v# ~- B& _  u1 w
   else if (yDir == "up") {
* U$ j, J6 u' F* L      if (yPos < (0 + BallSpeed)) {( o; [  k2 @+ |! s+ k6 y
         yDir = "down";9 H! o9 |* R* q* N0 V
         }! |3 Z* y1 ^6 E6 s
      }
, T7 ]6 w6 w# i; H+ ]7 G   if (xDir == "right") {
% h# ~* N8 s7 w1 C& s0 R      xPos = xPos + BallSpeed;4 Q, k) o1 d/ |' n- V8 h# \
      }' X5 }; N4 H* _) M
   else if (xDir == "left") {
, S# g* {1 E- R( O      xPos = xPos - BallSpeed;4 D" ^6 s3 j. Q4 W& [* S8 Q/ E
      }" X/ g9 O- \3 i, Q
   else {
) y  Y1 ?% z9 o/ K, [      xPos = xPos;6 n" D/ i" z6 Q, l) d" y
      }" n2 q, C& E( ]* Z
   if (yDir == "down") {
8 o3 M2 v5 ~% Z, F      yPos = yPos + BallSpeed;+ u6 {- ]0 [; r& g, C
      }- C/ W: ?, a2 D+ f1 @2 a
   else if (yDir == "up") {
5 K$ A3 f% v5 r+ Z/ A. {: _8 K      yPos = yPos - BallSpeed;
2 \! _+ C# `) n  J. V3 g0 ?      }
. c; E9 \# v$ x   else {
' w" o% G8 k3 [8 P. W      yPos = yPos;9 b: x4 ?) H1 J' W$ m
      }
, N, G9 S8 s/ d- W   }
2 G; y6 b5 \0 [5 |0 I) z  K# A" F' f+ Y+ S" z7 D% ^; E  g
function hidetext(){4 U7 h, f6 E  [8 I& f$ |( g
if (document.all)- k( s) f' t! D$ d6 C( T
supertext.style.visibility="hidden"
8 `3 a! m; J4 z. C( Qelse if (document.layers)
& [. i# a8 M. i8 v+ Sdocument.supertext.visibility="hide"' G  \  z3 j1 H5 Z
clearTimeout(animatetext)
8 Q! B7 ]1 R7 @}
, x6 a' U/ v" q" L. i9 c7 L0 `3 K/ [' ^* K' M4 |
if (document.all||document.layers){+ M. P5 h2 v8 q8 T
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
' h) Z8 d" V7 z. @( e( V% X$ F4 Cwindow.onload = initializeBall;
* ^7 k. H' U% H7 u  e. Q1 Twindow.onresize = new Function("window.location.reload()");7 E( E; T! g& l: S$ B
}" o, U7 D5 K7 P( O  M& f; {4 C
2 j/ a3 K# J. Q
</script>

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