返回列表 发帖

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

<style type="text/css">
' G0 U9 g7 D& k/ u9 f, Z#supertext {" E( f0 S, [, q0 ]7 \; Z% @
position:absolute;
7 v# J( u* S7 D8 G3 Xleft:0;
2 W9 \/ j* D# ?% K9 @6 C) [top:0;/ Y! {' k7 {4 g8 ^; K1 [
visibility:hide;
" s( w3 g; L$ P! ]" A( F# K2 }2 [visibility:hidden;. ^- w1 n; U* `' F& c# \
}
9 H% X; k6 e) x% Q, X8 B& C</style>
4 h  P2 N# h( ]) s/ n5 J<script language="JavaScript1.2">. Q) @/ Q5 ]$ Q: u6 l
<!-- 改变下的字体的大小。颜色-->/ _  O7 c& ^% k8 D8 u5 x6 X
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
( t: `# s, ]; Xvar hidetimer='';
0 T: q2 B4 A/ _0 e" j<!-- 改变下的弹跳速度-->
& i9 O4 P+ @, j3 f6 gvar BallSpeed = 20;
5 R: U: P5 j' s2 ivar contentWidth;1 j! H  k4 x( I
var contentHeight;. [! S6 y, o% x$ X  A
var maxBallSpeed = 50;, B  h& D  j+ i

0 n( B+ D9 U" W% K5 G* @% T* N" }7 a. C. h
var xMax;; o3 Q) q/ m8 J! L
var yMax;, P2 `& @" h; L8 N- x$ I) P  |8 n
var xPos = 0;/ {# ~. {6 q' {6 i+ q* y/ z
var yPos = 0;
, g2 `+ O; |0 N  C" cvar xDir = 'right';
7 E8 z. ^3 `4 F. {, L) O4 Wvar yDir = 'down';
/ x& ]. \4 m& C' {) \' k' Vvar superballRunning = true;6 f8 Q8 _3 ?; n5 a" O# T9 h9 R
var tempBallSpeed;& M9 a9 n1 g3 [) |
var currentBallSrc;
, a3 p6 x7 o& |  j1 Y$ w  b4 P, T' mvar newXDir;3 a  L! m  |" N; s1 s; g
var newYDir;8 N* ^3 f4 r, H& C9 @% P, T6 K9 Q

3 d5 _# i7 m3 ]- ~% n' N# m' wfunction initializeBall() {
6 L( r* }# O/ o) I$ Z0 p4 G   if (document.all) {" t/ U. e. z4 e  g7 n9 x3 x, P
      xMax = document.body.clientWidth/ c5 i1 _" P) K
      yMax = document.body.clientHeight" `0 ?9 K; L$ O, h( f/ E) }
      document.all("supertext").style.visibility = "visible";
/ q* c, x: k3 k1 c& X- [5 ^      contentWidth=supertext.offsetWidth
0 ~# l" J0 N: ]: }( |4 V      contentHeight=supertext.offsetHeight
8 b/ L8 ?- m: O, o( P3 m      }- i1 L- b' z+ ?) v1 \
   else if (document.layers) {, v3 q& d3 O" G0 D' `: ~
      xMax = window.innerWidth;- K" h7 B& j; W- D( M- o
      yMax = window.innerHeight;
2 H, e9 F7 E; k5 s  f% T  G      contentWidth=document.supertext.document.width/ x, L$ E! N8 F
      contentHeight=document.supertext.document.height
& T: E9 _1 U+ P6 a      document.layers["supertext"].visibility = "show";2 s9 P5 K( A$ t& o7 v
      }
/ @# x( g- @( Y  L   setTimeout('moveBall()',400);
/ R: B! r1 D& E   if (hidetimer!=''); q! G' `% L) T2 a/ G1 m
   setTimeout("hidetext()",hidetimer)
, u3 @3 r$ v. |, X7 g   }, R$ W; F; j0 E

; R0 F, R! g& c9 q* X. e* Hfunction moveBall() {6 t/ n3 k8 Z' G5 F" ], X$ W
   if (superballRunning == true) {% s0 A; O2 \2 L3 ^9 h
      calculatePosition();
; u" Z2 X5 p% E/ c      if (document.all) {3 ^1 ^- K( G, E0 g" w! T% O8 q" v
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
- P! `$ `$ `+ l; @6 M0 t         document.all("supertext").style.top = yPos + document.body.scrollTop;
% M" c: y% O/ v, X* F+ C/ V% M8 I         }% G# w$ ^& `' b) ~3 [
      else if (document.layers) {' X) c! Q$ ]4 u% i# Z% I/ D% g
         document.layers["supertext"].left = xPos + pageXOffset;
, w1 z4 W" c! u8 K2 G         document.layers["supertext"].top = yPos + pageYOffset;
  X6 N1 Q4 X$ N/ J& m4 |; Q         }
! K1 X, i" b3 e: r, j      animatetext=setTimeout('moveBall()',20);
- X! e! T+ N# i      }' k  k6 R* e: [# ?5 p9 o# Y6 d
   }
, G5 p* l+ `; s0 f$ E2 y! T; O- r/ R( M; {1 {  x8 N: Q& F
function calculatePosition() {
# i4 W: x0 H" P1 T* Y' S   if (xDir == "right") {
. K+ i% `+ `' \: e- b- h- _      if (xPos > (xMax - contentWidth - BallSpeed)) {( e, V5 m3 ^1 O* q( D
         xDir = "left";
+ ^0 [; ?# L/ u; n         }
' o  _( V( N* ~& R. k' n. E" n      }% o" t/ d9 ?! ?$ ]2 k5 O- U3 ?" x1 y
   else if (xDir == "left") {
4 e5 S$ n( J; q& Z/ U      if (xPos < (0 + BallSpeed)) {
# `) f1 R8 e/ D$ y2 N6 D( j$ F         xDir = "right";& U4 G9 [3 u$ M  m6 }
         }
, G8 g+ V; a) Z- c: W1 z# k      }) r. ]  `5 {9 c! i
   if (yDir == "down") {
& A9 ~% @: z! m- {* D      if (yPos > (yMax - contentHeight - BallSpeed)) {' \$ ^3 B3 l5 d; P& X$ a" B
         yDir = "up";
' Y! d$ u) J; J3 ?         }
9 `# i  y, F0 a6 N) H/ M      }
* \4 v, R1 E7 Z/ }% _# b8 ?# v   else if (yDir == "up") {
2 Y4 i8 Y* [$ N' g( T$ G0 v      if (yPos < (0 + BallSpeed)) {
7 R/ i! i0 P, P, D7 s8 F         yDir = "down";
9 c) ]/ J2 Z# m. [: [- d6 {- J# u         }' e* P5 h/ J; T8 {
      }6 ?" e# z8 j. l4 r% P9 y: N% M& |
   if (xDir == "right") {1 U2 Y. H  N: N: I
      xPos = xPos + BallSpeed;. h! P4 n' P( u$ D- i5 R! W7 m9 }
      }. w) y. c# Q9 S+ L. ^
   else if (xDir == "left") {2 `5 j3 m8 v. z  c; l
      xPos = xPos - BallSpeed;
2 i+ n/ L8 k( ~      }
+ v* g# z$ R1 i. c4 T! N   else {# U1 ?+ Z6 Q; I6 W% w" p/ G
      xPos = xPos;
2 [8 J# }/ X' d      }
1 m* x) e9 r7 a- A& }   if (yDir == "down") {
# g8 V* m9 T' _, j2 \2 S6 [& T      yPos = yPos + BallSpeed;
) ^$ c; d9 [( h9 i: ]  `      }* h' N0 u% [' U: h7 n+ C* o3 e
   else if (yDir == "up") {/ {: L7 ~, J2 V
      yPos = yPos - BallSpeed;
0 A# y3 a9 O# A4 t# ?      }
/ f; [8 s% O- P' g" U  l( |   else {
- @! @) L3 l  m# R/ g9 ]      yPos = yPos;
; Z* m1 {! M- D+ m- `      }3 p8 p5 g* q/ S  P
   }2 R: }# F" t+ Y' |3 ^9 D! v

' \5 o3 {( t- k( ?# V* |function hidetext(){" h& |7 {/ J3 R
if (document.all)
# c7 x( y& f9 Z7 y9 Y% R3 jsupertext.style.visibility="hidden"
2 S; w4 b* ]7 r. }' Jelse if (document.layers)
, I8 y3 N& O* |. n) wdocument.supertext.visibility="hide"
- G) a; E3 W: W% \  W6 }* b7 UclearTimeout(animatetext)
; \$ R& _; b- D) V1 r}
& ?" i( `1 O. A7 i( {; p6 u! o; D
; L' H# l/ n/ N1 I" e4 x. Tif (document.all||document.layers){3 B+ u# ~( S8 u% E3 Y$ D& s8 _* U% A
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>'). j# \5 Y5 U# q9 \; Z# F8 R
window.onload = initializeBall;
! J$ k% s& N+ F: H. gwindow.onresize = new Function("window.location.reload()");
% m6 G/ h3 S, R2 v6 j1 m}- n$ X3 o6 A0 ~

+ q' ~  A) J6 N  b( r: x& R</script>

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