返回列表 发帖

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

<style type="text/css">
5 y6 v) T7 e: _' k4 n. z1 M7 ?#supertext {
# |* {$ M( N/ W0 Q& Pposition:absolute;
& \3 F' b/ z- g2 T+ q7 m/ cleft:0;$ A, u7 w0 Z  F) r
top:0;
  `& [% r. _( t, Bvisibility:hide;" w) r- N; ?* z& r( w
visibility:hidden;
8 j8 u1 I% s- E# n& Q9 `}
# `, h5 ~* N  Y</style>
& n# c9 ?/ W/ d3 i7 P<script language="JavaScript1.2">
( w% f7 z0 x8 v# A6 r# x( o<!-- 改变下的字体的大小。颜色-->
0 g2 X0 C" l% V; `) qvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'3 t9 z9 R* w6 a
var hidetimer='';5 B# y8 G7 @+ F& O- c, V' ~6 M
<!-- 改变下的弹跳速度-->8 H$ d0 h2 D* u& [7 M9 ]
var BallSpeed = 20;# y9 F& z6 Y, I  M9 C2 q5 q
var contentWidth;. a( x0 f" a" S
var contentHeight;/ V* g4 U! z( d# ^! l5 R4 B6 c4 E2 K
var maxBallSpeed = 50;
# C& Q3 u/ S2 C1 Q- F
. u7 y; R6 A8 ^3 p( z+ u" Q2 N) H: f/ Z  F9 S; _; s
var xMax;: d/ h9 v( |/ D' c, n4 X
var yMax;& a' F0 q' Z6 I4 \1 W
var xPos = 0;
* W9 b  ~3 g9 h  Y) f$ r; D7 Cvar yPos = 0;( e% @7 e$ p; ]  g5 T" h
var xDir = 'right';( c* `' r0 Z0 s; J
var yDir = 'down';
  g8 a5 ?& l# O* w% n9 ]var superballRunning = true;; G. C) i: H/ k! ^
var tempBallSpeed;
  c( h9 f& i, i* G2 |var currentBallSrc;
0 R: w! h: M# z$ @var newXDir;# M  P8 u, {' D
var newYDir;
0 P; a8 R* P+ F2 R4 B; m" I% A  @; S% K7 c$ S
function initializeBall() {
/ t) e* B! @# K. C7 h% k( U; _   if (document.all) {5 {/ N( ^9 n6 L, I; B0 X
      xMax = document.body.clientWidth
' o1 @$ U1 u- B6 M/ I/ F      yMax = document.body.clientHeight
% f' S5 y  ^2 }( L! U      document.all("supertext").style.visibility = "visible";
% {0 K- B0 B/ m' Z9 v5 R      contentWidth=supertext.offsetWidth" h0 y$ s2 ^$ I  l
      contentHeight=supertext.offsetHeight
- ]% P0 ^% C5 U! g& F; i      }
5 L! Z) Q2 m. M4 j- t8 I   else if (document.layers) {
* @7 j, Q1 `* E( Y      xMax = window.innerWidth;
5 ^: B+ q$ C2 Q& H# z      yMax = window.innerHeight;' ]9 P& I* @/ z6 u; O
      contentWidth=document.supertext.document.width0 e' z% H% g6 h" m+ X8 ~3 }1 H
      contentHeight=document.supertext.document.height
0 \' A" z; `+ p# i! T1 V; n      document.layers["supertext"].visibility = "show";" P: T) D  F! `( ~4 W! ~
      }5 Y0 h: K& k/ X) t& g" p
   setTimeout('moveBall()',400);  e& ?9 A) k3 R# {# m4 W+ J
   if (hidetimer!='')& W7 P0 O3 @+ ^' g* S
   setTimeout("hidetext()",hidetimer)7 ~7 n& p/ h% M: S
   }
0 H6 J' u0 Q; h5 j
* y2 M- C) ]5 ^9 N& S7 j4 }/ ~* ~function moveBall() {
$ T+ r3 U! o4 k& [" \) g   if (superballRunning == true) {1 `# w: A! P& N! V+ y
      calculatePosition();
9 ^1 o1 e8 B9 u( F$ D2 F! v      if (document.all) {
/ e9 }* E* e2 @8 _  |2 a% u) e         document.all("supertext").style.left = xPos + document.body.scrollLeft;
; C1 T! z) }& J0 ]) A6 l5 {) A         document.all("supertext").style.top = yPos + document.body.scrollTop;/ y6 m- }9 ~( ^) k; w- i" N
         }
: J) D; \2 P, m" U6 M      else if (document.layers) {5 Y1 d3 L( X8 |# Z+ N. ^) b
         document.layers["supertext"].left = xPos + pageXOffset;' j) K2 c- C2 H5 |, P
         document.layers["supertext"].top = yPos + pageYOffset;- u: t; R' B5 t, ?8 W$ a5 X* N
         }
- I7 s, d% M) _; c      animatetext=setTimeout('moveBall()',20);0 z' N5 k/ m6 n' @
      }
+ l; \1 |. n. Q   }
* V4 J8 r% J& m) ]1 q* \0 _7 D* d. e3 ?
function calculatePosition() {. ]. ^" L3 u$ t$ V' ?8 v/ i
   if (xDir == "right") {! `1 a/ Z, t" `- G! g- o
      if (xPos > (xMax - contentWidth - BallSpeed)) {0 a9 X7 K% e4 E
         xDir = "left";
+ D. W5 E% ~! N$ S2 s% z         }$ t) q2 }/ W- V- J( B$ `7 k
      }
7 X2 M, @1 _0 P  A3 f% g   else if (xDir == "left") {+ p9 U+ d$ d: p: L$ ]
      if (xPos < (0 + BallSpeed)) {, [. q0 p" H% ]% z- w0 h8 h
         xDir = "right";
& ^# E- V% C- }& v! z         }
7 s) |# K3 s) B/ T* j, u1 w      }4 D( N$ r2 ~) @# F% L+ r# G
   if (yDir == "down") {
8 r  Y" [1 P$ {      if (yPos > (yMax - contentHeight - BallSpeed)) {
/ s  _, S: i, n7 w) n% l         yDir = "up";
3 r. q: [0 ~' g         }
& f# C8 D+ c! X  Q      }, ^4 I* `  r( L" e
   else if (yDir == "up") {
+ X- j) a) A  a% h( ~      if (yPos < (0 + BallSpeed)) {
) e. K& @- C  B3 P         yDir = "down";
; {0 K: a6 Q3 ~& @9 S  x3 N         }
6 X* X# M$ o2 |7 h# F      }
1 B+ z- @; e2 @   if (xDir == "right") {0 _1 l/ T! m3 d: c* R
      xPos = xPos + BallSpeed;- n5 r  |- d- \/ V
      }
" D9 {' ?3 X2 z" {1 |   else if (xDir == "left") {4 v- r3 B/ I. Z* A
      xPos = xPos - BallSpeed;
% b1 `5 }& V4 A) M      }2 `; }* X) A) y( M5 ~
   else {6 J& Y# K% |. H% |
      xPos = xPos;
, C) Z- g0 O. @! Y      }, V1 H$ F( Z9 i
   if (yDir == "down") {
! f) ~0 O/ i) M' @      yPos = yPos + BallSpeed;
$ k2 G- E% V7 `  W$ t      }. d1 Z! n% N6 }
   else if (yDir == "up") {$ R. r# j: ~5 Z; J$ Y2 _' v! s" n
      yPos = yPos - BallSpeed;
3 _. }0 }/ D5 I9 Q5 [; @: X! g7 M: c      }  K2 a( K7 \6 f% J/ l
   else {3 P5 ]6 }5 C4 U" u
      yPos = yPos;3 \( f$ s) L; q) A& J! g; E
      }
$ \; ]% `' t. t; c2 o% c6 ^( y   }
2 B6 g4 \) G0 u
# Z7 w) ~7 |1 m% Q6 A9 wfunction hidetext(){/ b. ^$ ?; z" s' k" h! U8 a9 }
if (document.all)( a3 M* @/ s3 x3 r! E
supertext.style.visibility="hidden"6 y9 A6 y2 l+ r- u
else if (document.layers)
/ \: {1 J) p4 Q7 c7 j! mdocument.supertext.visibility="hide"
4 z) D! [3 D: K$ s, v- dclearTimeout(animatetext)( O2 V0 `; T  O! _4 |, c$ S
}
( \3 O8 ?9 j% I7 i5 f3 H- J) m) Z# {  G4 I) \, L
if (document.all||document.layers){
! \2 [2 Y, A& r  p9 s7 Rdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
( ]5 G7 M  T' S  o8 nwindow.onload = initializeBall;6 q* n+ O7 ]# Q
window.onresize = new Function("window.location.reload()");3 }- w5 s- {& m- C
}, g, U9 X- r2 Y' L5 W1 G
% D0 p; X( U3 N1 u" D
</script>

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