返回列表 发帖

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

<style type="text/css">1 U& |' D' J3 E# A' J
#supertext {
2 f- I, X# A" N" O) V6 `position:absolute;
' I; ~- Y/ C- o1 Q5 P! ^7 f7 q+ ^left:0;1 n, ?; |! r" C0 J4 l+ n$ n
top:0;
4 C0 o8 t# z) M0 c! |visibility:hide;# o; [1 U, i; Z5 Y$ Y. M6 J
visibility:hidden;
9 ^. Q* K6 B6 z8 y+ Y}+ q. d: m- }* }6 [2 q$ W
</style>* D3 M* W1 L/ m% G
<script language="JavaScript1.2">
' x& N& J3 r3 [& n5 X8 N<!-- 改变下的字体的大小。颜色-->- e" k; v& [3 |8 @6 f+ A
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
8 D2 Q8 P& ~' evar hidetimer='';" Y, Q6 }. Q3 F7 ?3 ?
<!-- 改变下的弹跳速度-->: H, s* G) X, P" ]: L1 j# N; V0 |: z
var BallSpeed = 20;
7 q( P2 n" k4 P8 ?9 mvar contentWidth;
6 @* h# {5 @0 V; Bvar contentHeight;
+ r. @) ?' [+ V/ e6 \9 N. bvar maxBallSpeed = 50;
7 p& z' |0 Z8 g/ T( u- ?8 T2 v) M* R8 ]3 I+ S

9 X8 o$ j/ b1 o7 N0 Wvar xMax;
0 U" X4 w7 P3 vvar yMax;) J0 Z$ I8 J. S1 u& z- d
var xPos = 0;
$ g# j# N5 W' n/ S3 a; Ovar yPos = 0;% l5 g0 _% U+ x- L" {2 `. d
var xDir = 'right';: v1 o; N6 [+ I! r3 m
var yDir = 'down';
7 _+ {( z- F* E: n. Hvar superballRunning = true;
# |% h5 y1 s  v% C1 C) B& J# t1 Zvar tempBallSpeed;6 y4 x9 C5 T; }
var currentBallSrc;* I) I8 g; _# k" `- t
var newXDir;) F9 k- e' l8 x1 f+ b
var newYDir;4 D5 ?! N% N7 h$ i

- c8 p* t" f/ l( t* i# G8 d: p1 h7 f7 jfunction initializeBall() {
$ U3 j# u$ @7 Z8 y0 b   if (document.all) {3 p" J2 i3 b/ y0 Z) o# u) M6 |
      xMax = document.body.clientWidth
9 f  Z- i4 t1 v2 D% W; k3 J      yMax = document.body.clientHeight3 M3 r( c9 q  I$ t3 X
      document.all("supertext").style.visibility = "visible";
5 t- G4 R) a/ l! x6 e0 m. s      contentWidth=supertext.offsetWidth
( Q/ D1 P9 m7 ^6 p, a/ w      contentHeight=supertext.offsetHeight
: Q: i8 ~/ j' K5 L& ~) h      }
$ B) y4 o# u* d. e0 F. q  A   else if (document.layers) {8 H, O# d, S0 e& w
      xMax = window.innerWidth;2 D# U  O, p+ Z8 \6 w" |& c8 }: D
      yMax = window.innerHeight;5 O- T- c, d( k8 R7 s6 R$ |( U
      contentWidth=document.supertext.document.width7 e$ T5 d/ @# b  o5 f
      contentHeight=document.supertext.document.height
6 n: J2 \1 x1 O* T      document.layers["supertext"].visibility = "show";
$ L9 z* k* z3 ^1 w0 C) d      }
8 j9 v$ u# A, t/ L0 d   setTimeout('moveBall()',400);3 }* h; M  d# N" v+ {1 ^1 j4 k$ ^
   if (hidetimer!='')
- `% V% z& ~7 z1 ]( y3 i8 s4 L   setTimeout("hidetext()",hidetimer)
7 D! l' i& R( u7 L. Y2 q6 D   }* q& Z8 m5 n" n* H
3 ^9 k, O& h9 s' [. E- Q: E9 v
function moveBall() {
( R2 I' ~0 i6 s0 j. _3 H' B& l  A( \   if (superballRunning == true) {
- }1 C/ l% w, B, w7 Y      calculatePosition();
; x) D7 E/ A! `& [; V8 Y      if (document.all) {
$ ?- [7 V7 J) d7 ]9 d         document.all("supertext").style.left = xPos + document.body.scrollLeft;$ z# ?! Y# N5 _
         document.all("supertext").style.top = yPos + document.body.scrollTop;
  {% W0 C5 ?- y4 J' L  h         }
4 s0 c- O# s7 j8 Z1 I      else if (document.layers) {
/ N5 |- i6 D5 I* T5 K" J) q7 w' Y         document.layers["supertext"].left = xPos + pageXOffset;/ Y, j% T. [' Z  V% }
         document.layers["supertext"].top = yPos + pageYOffset;
& U7 b: M+ W& a% v  A: w! {         }
7 k+ F7 T1 _4 D- C' A# Z) U  x      animatetext=setTimeout('moveBall()',20);: X4 p" `; u: C' ?
      }: U) U) A9 ]0 l% D0 Y: y" U7 D
   }
' ?. V% N6 n3 e6 W+ h( F" w
( ?( Y. g- N& F) Afunction calculatePosition() {" @) [$ \% L& ^6 {
   if (xDir == "right") {/ r! V% A/ }7 d( I
      if (xPos > (xMax - contentWidth - BallSpeed)) {8 t3 [0 }" ~6 [4 c5 F* [, K
         xDir = "left";# m, T5 `! ]. u& n# \
         }  p8 H# |% X- Q1 N
      }: q( G7 Y  _+ e, V5 K7 K! t2 L
   else if (xDir == "left") {- z  W" Q8 J7 v& i# }8 X( `
      if (xPos < (0 + BallSpeed)) {
  B9 |# V2 |. H0 I1 V9 Q) y! e         xDir = "right";
5 a( l  U% V1 p5 F/ z' v         }  o& T0 K" N9 d
      }
! V7 Y0 [4 y) I5 P6 j% r/ L   if (yDir == "down") {3 A7 g' I# c2 Z- u# v1 ~7 O
      if (yPos > (yMax - contentHeight - BallSpeed)) {/ E5 v9 T/ w$ T+ W5 \( j; E
         yDir = "up";
' J) \! q& s7 ]  D  s         }
2 b6 k; T% ^3 t1 X& Q      }: M! c4 ~) h- v" ^5 k% O( Z& X
   else if (yDir == "up") {; X( \# W) B8 M! E5 S" |
      if (yPos < (0 + BallSpeed)) {
% e5 l/ ?3 y0 b         yDir = "down";
! ^; U* A; m8 n$ f$ v. y         }
# S8 P( _* o" B& q4 k* {      }
4 n. N2 S8 z* ~1 O( E, S1 b& p   if (xDir == "right") {
$ _! s1 @; |, Y  x% p+ c7 G      xPos = xPos + BallSpeed;
4 u, ^1 x. N6 A) Q. c# z$ _3 {      }) ?9 e  |9 Q/ f# I! A9 S  p
   else if (xDir == "left") {2 A4 t" w9 E5 `# I
      xPos = xPos - BallSpeed;3 R4 c2 D2 p6 }( y) M( W: G
      }, w3 Y1 F3 x* b/ [8 x. B$ C! D
   else {
5 n# J3 c2 s& I) H  J& T      xPos = xPos;
, C6 O; d: C- R9 t' T      }
5 R- c) U/ `6 u' T- |4 N7 ?   if (yDir == "down") {
+ s7 _6 M( U% l% `      yPos = yPos + BallSpeed;# F, c) j9 X9 Z1 x8 a
      }
( `  R" T, @: h8 {   else if (yDir == "up") {
9 d" R$ F4 U0 r6 N6 k$ `+ W      yPos = yPos - BallSpeed;
- O4 l$ ]3 W9 ]6 Q      }
- d# [' g+ _; A/ S: M   else {
* r% J& ]1 Y3 q! i9 y      yPos = yPos;  r3 g! Y5 r9 ~6 \, t# j
      }
1 t1 v$ i( `* t! c+ ?% {& ?   }
/ ^7 m6 u9 B& `, |* W5 G
* d) {: L* M5 \7 {+ hfunction hidetext(){
2 J. m% s! M9 {) E& Zif (document.all)) t7 R. A3 g& L( e6 c- X+ a2 a
supertext.style.visibility="hidden"
' L8 g- k: v4 W2 e0 h5 @else if (document.layers); k! N& Z/ O8 `- N* M5 s8 b
document.supertext.visibility="hide"
/ U4 S. ]  U! q$ S0 L" O( UclearTimeout(animatetext)$ a6 ^4 N6 }. {+ F4 J! ^9 C$ W
}% ^0 P8 R! l* Z# A2 {% g, V

( q: w7 k% Q' n. l2 [if (document.all||document.layers){0 _, E0 N% x5 M8 G( ]: [
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
/ o% C3 d% W# x  w8 r, F9 Q( [window.onload = initializeBall;( r2 V, F! ^. |) s8 Y
window.onresize = new Function("window.location.reload()");
  W4 l0 \0 i# _  O( I2 H( k}+ c' ^" z' d3 q/ N/ M: n( T

! ~' f3 u, G( R+ I9 p/ A  X</script>

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