  
- UID
- 133
- 帖子
- 51
- 精华
- 1
- 积分
- 186
- 金币
- 55
- 威望
- 2
- 贡献
- 0

|
网页之不断弹射的文字-特效
<style type="text/css">' R+ r: T$ _) U) l$ t# @
#supertext {1 G! D4 S1 B1 \3 s
position:absolute;
0 v$ L2 p+ N9 ~left:0;: B. w0 b; ]+ @- e
top:0;
. i5 K. |: x4 K/ Dvisibility:hide;" b' F& C0 d$ s/ i! u: E
visibility:hidden; z7 F& ^; o# A& T
} Y8 v% n# w* V" g2 X
</style>
; o$ Z4 g* A& d<script language="JavaScript1.2">
0 {; f2 V* _) N3 U$ Y5 H+ Z6 f$ s<!-- 改变下的字体的大小。颜色--># y" d( h0 W9 A$ m4 Z5 D7 [6 Z
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
: f1 g' S& I3 V/ I: X4 zvar hidetimer='';
9 X4 m$ d9 d& V; w) o<!-- 改变下的弹跳速度-->
7 ~8 d! s$ |. W* ]7 v: kvar BallSpeed = 20;8 _- c3 X. j" H5 Y, P
var contentWidth;: A; n. q, D1 i# N4 Y% E8 N
var contentHeight;
7 j' I# v" e6 K8 S* J5 ], @. S) Ivar maxBallSpeed = 50;* P6 N! U! d2 y6 }9 F
, A* Q, g/ A$ c& r% T. I- ]1 I1 B, w% ]# ]7 s) X P
var xMax;" w% c' r2 G, T: g9 g% Z
var yMax;
p4 Y! E7 ?% v' `var xPos = 0;2 a( z, y! ~% e! n% Y
var yPos = 0;% b7 ~4 m9 A( c1 I
var xDir = 'right';
% o+ I8 c. ?. s1 Q! l; ?0 U; d3 @var yDir = 'down';
4 f* t' Q' p g8 j+ Tvar superballRunning = true;
$ V. Z! f8 k/ E4 q9 V2 I) \4 E% }var tempBallSpeed;; X% Y7 j8 X! Q
var currentBallSrc;
$ f- }+ |% @& \5 q: u5 jvar newXDir;" ?5 g8 B3 R3 T2 _$ m9 @
var newYDir;/ h0 w! z# T8 Z, b! u4 q H+ B
% L9 U5 N+ }9 y6 |function initializeBall() {
5 y$ j& L" {: A x! |* D if (document.all) {
4 F: T; a- P; j) V xMax = document.body.clientWidth. `5 ~# @& O6 z. V Q) q5 \! V
yMax = document.body.clientHeight
. I4 ~8 {7 Y J document.all("supertext").style.visibility = "visible";+ L% v) d: g+ {) O- ^
contentWidth=supertext.offsetWidth
( e: @8 Y; F5 E! c contentHeight=supertext.offsetHeight
8 g* I Z9 c. a9 h }$ g. }* {+ d$ Z f; k
else if (document.layers) {
/ W" @9 \/ s; i' b) y xMax = window.innerWidth;
1 D! J) H* D, Q* Y7 M yMax = window.innerHeight;
) M4 T' k3 p2 r0 u6 U9 D0 a contentWidth=document.supertext.document.width: P8 L }7 P6 J* ~4 Y
contentHeight=document.supertext.document.height9 i% T- g" z4 A1 P1 N; C: M
document.layers["supertext"].visibility = "show";: O0 ]- v T/ N8 y; s) l' q/ }9 m
}
7 @; x3 X2 R! O" @! S2 D( ? setTimeout('moveBall()',400);% W; a: w, \5 Y4 p
if (hidetimer!='')! Z" o5 N! {" P! _& Q( Y5 I1 n
setTimeout("hidetext()",hidetimer)$ u0 W& j3 R! V1 A. l* _: \# t1 Q
}
6 [$ g/ y# d1 D3 z$ X6 s; j# D
0 i/ c# Y$ ]+ k. a5 a, Lfunction moveBall() {
: s7 g7 a8 f: |1 t0 j' k) v7 q0 F' a( S if (superballRunning == true) {
. j/ e w/ v+ X: ]- c/ u calculatePosition();
. u% h% N. R- ?. h a7 l2 f if (document.all) {
* r8 Y6 W- Y9 l4 `9 E document.all("supertext").style.left = xPos + document.body.scrollLeft;9 d, k6 w1 Y% p7 }7 X/ j
document.all("supertext").style.top = yPos + document.body.scrollTop;
, N M" l0 g9 g9 }: l }, P$ |1 I* E" M4 w3 ?
else if (document.layers) {+ l. n3 R4 d* m' R; l
document.layers["supertext"].left = xPos + pageXOffset;% l2 ^' ~8 z1 c% ]
document.layers["supertext"].top = yPos + pageYOffset;
: _9 g# h' o$ U( f3 u" d7 z }. }; h' z) D' Y# {* |3 ^* b
animatetext=setTimeout('moveBall()',20);6 W; l* D. H" x3 u
}
; z1 q% R8 Z& {# g6 T }, X) `' y3 R5 {5 |/ M. o3 a
# y& `% d( u+ y# b! R% h
function calculatePosition() {6 k# s" l& d* V! y! U' d9 f+ }8 \4 v" j
if (xDir == "right") {
* V( R8 o" H) W9 L) _& m if (xPos > (xMax - contentWidth - BallSpeed)) {
7 q2 Y; u0 C \9 D- d xDir = "left";4 c) Y/ c7 m' @, ?* Z
}" ~ P4 v6 f6 v0 {1 a" a$ k. J2 Y
}/ H" z: u- p" G% p
else if (xDir == "left") {
9 A( V9 F( s* Z: m+ E if (xPos < (0 + BallSpeed)) {
5 \$ O) ?1 v% \$ g/ k% o xDir = "right";. b) F& M/ r% P6 N" o
}
% A2 b! p K* H8 W }) ]( i# O6 K% b5 M/ h8 e5 b' B
if (yDir == "down") {
9 Z' G0 j5 ?: V" X7 H/ i' W if (yPos > (yMax - contentHeight - BallSpeed)) {
7 ]% j! b8 }0 B1 D yDir = "up";
1 g6 O' k+ x( Z& h& F }' ~& ~9 o* s ^# G5 v3 E
}- T" J1 }" O8 m3 M$ v E* f6 d
else if (yDir == "up") {. h3 B5 t1 J5 Z9 x* X% O. f, Z& Q
if (yPos < (0 + BallSpeed)) {
3 ?! J( i# g" U3 }: H' ~; ] yDir = "down";2 @+ o6 L% ^& u$ S5 P/ p- C$ q' R; T
}
" v3 Y4 D; Z. L6 C } G7 O0 L+ h4 j, ]* b2 V
if (xDir == "right") {9 P6 g0 m, q: H% E
xPos = xPos + BallSpeed;
( U( U; s1 f# ?7 G& \ }
4 w0 C2 W- ^# g' r, v else if (xDir == "left") {
3 [' w5 l( j% W9 R9 r xPos = xPos - BallSpeed;. Q8 j0 N% G& e' @9 s0 v. o
}
1 A; w2 b( ]/ k1 ~ else {
, S+ d3 | ?( R" O xPos = xPos;! F j- z# J3 |8 m* S, z
}
2 J- y; t1 A) I- d if (yDir == "down") {
- s4 [; F% Q( g4 h( D8 O yPos = yPos + BallSpeed;& u( s5 Q* i9 W: F8 k8 O/ l H
}8 S1 E9 u) ~0 T/ o8 s$ j9 c
else if (yDir == "up") {
+ ~- g( F( w6 ]0 q) |" b+ ~ yPos = yPos - BallSpeed;4 ?& o* ~: q* j) R( L5 v$ S# _
}4 p( E! O. l7 o; y+ V* C& k2 g
else {
& F% u8 T" q y0 x H( Y- i% w yPos = yPos;6 F! m5 i$ b( g, u$ D) [
}
" ^+ V9 i5 p% W. p; V; E }' u6 F. W# J5 N0 K4 o2 Y
" i8 W/ A# O7 F9 ~1 P. @+ j
function hidetext(){
( t# r% ?9 G' \- |# ]if (document.all)
4 p/ l% u0 ?' B( n) Xsupertext.style.visibility="hidden"% Z$ q" w, a5 h* V4 @' s$ \3 e* O5 e
else if (document.layers)
* I4 A/ G. O* S, |1 Edocument.supertext.visibility="hide"' V, f- I1 m% _ @: |% ?0 v
clearTimeout(animatetext)- I9 X: \) e& Y: a# \9 Z% T7 q
}
! Z, T# Y( D. }4 f8 O% [7 q% @% C" U" `! w, t, `& s# Z
if (document.all||document.layers){
9 c6 t, ?/ |0 \! D) |9 ldocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 g9 O: o2 g* U5 a; vwindow.onload = initializeBall;
' j: u- H/ F3 u1 ?, N! C+ gwindow.onresize = new Function("window.location.reload()");
9 |( ^6 W w- w6 D+ q4 ]}0 `& F z3 h9 W9 S' P
/ m& i4 R8 f/ P9 O
</script> |
|