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

|
网页之不断弹射的文字-特效
<style type="text/css">& i6 d2 @3 ?! J* M
#supertext {$ w' f. k) F, H. z9 Q/ ^
position:absolute;2 |, F _# a) s9 l# S$ e
left:0;
/ z& ?+ Y5 R1 s K# j' ]top:0;- w+ K/ [4 ^$ z# H Y/ m
visibility:hide;
7 L9 n2 G( Y$ Z+ |( v) Hvisibility:hidden;# G' R; k+ z% v& b! }- B9 @; H
}7 }+ ~# i3 u" o* m# D: ]
</style>
' ^# A! S* ^) T& C( x1 P ]8 ~. Q/ w<script language="JavaScript1.2">, ]7 q% T7 K, q4 p% B; P
<!-- 改变下的字体的大小。颜色-->
1 ]4 H; E- J" s, o5 }5 g8 w1 z% fvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
% {, z' H$ ~0 B! c1 l) [0 x% X3 rvar hidetimer='';( c4 D/ L9 \8 q+ l* c3 Y+ ?. v+ p
<!-- 改变下的弹跳速度-->
5 z) w& V, C0 q7 T# d: Lvar BallSpeed = 20;% k( E# ]. ] x" d' e3 i' y
var contentWidth;5 U; C& K/ {& o( X( J$ O' o. d0 J
var contentHeight;6 q2 d( @- ]2 q" n
var maxBallSpeed = 50;6 B) ^" h; M6 T# I7 X
' r% a3 q/ w+ S. S2 `# B3 ]+ s% U* z, Q
var xMax;
5 h- H) e/ X. v2 y. i% U% X% Q2 Y: Avar yMax;% k- n" g/ }% x& r; }) q2 o
var xPos = 0;
6 i: ~6 c- {: d* M+ X( ^' L! Xvar yPos = 0;, A4 i0 q6 O, J/ c
var xDir = 'right';
! y" M7 n% y; Q6 fvar yDir = 'down';/ v! q+ R' y/ g1 w/ t
var superballRunning = true;2 o( r4 P4 f4 x) l
var tempBallSpeed;3 b. v- }4 j; U: `. w. m3 v
var currentBallSrc;2 i( Q V2 H/ \
var newXDir;
9 S o* X0 g* W( V5 t( ovar newYDir;, M/ t+ k% b3 o# N3 T$ B( p
5 q- E( H4 A$ l! J X/ z1 b
function initializeBall() {+ G5 R' H+ m9 ^( I4 d, M
if (document.all) {+ k q9 W/ y& w5 |5 W
xMax = document.body.clientWidth3 O- O! s2 V2 ^, j R/ x: x3 P8 q
yMax = document.body.clientHeight5 O. n) x! V6 C( b2 n
document.all("supertext").style.visibility = "visible";3 Z9 Y( \: L* W
contentWidth=supertext.offsetWidth
6 a) F3 ^5 r# P( @ contentHeight=supertext.offsetHeight, K) H4 V8 e T! ?; {( ~0 x$ @" J, o
}5 b' Q9 k' E; s3 \* v4 X* G
else if (document.layers) {$ f" U0 q; k" f5 h8 R/ f2 [8 b0 m( x
xMax = window.innerWidth;
: I2 h/ l8 [. w yMax = window.innerHeight;. J( i+ u* I7 M1 O
contentWidth=document.supertext.document.width
& y7 ^" k+ c% b contentHeight=document.supertext.document.height
3 p3 n3 a: Y& K3 e& h. U; s document.layers["supertext"].visibility = "show";( u3 {( C' @! c# r
}% b3 [1 u0 P' P) |* a' a6 Y
setTimeout('moveBall()',400);
* r# a% M( }1 m& i& \- d3 e if (hidetimer!='')
7 b# C, U) C, q setTimeout("hidetext()",hidetimer)
t! F, ? a' }1 n, \- N }$ u# y `% }! y& i; E/ T
! {9 Y. E1 E1 c% {3 I6 n" Wfunction moveBall() {0 X w$ g: I4 j* i/ `4 C/ ]
if (superballRunning == true) {
4 Y) i7 n6 U* \. P% f calculatePosition();1 _& T1 L3 L Y o- Y2 g
if (document.all) {- ~* Y! E- i8 l a7 J9 y% b
document.all("supertext").style.left = xPos + document.body.scrollLeft;* o2 L+ R1 z9 U. [( L/ L7 o
document.all("supertext").style.top = yPos + document.body.scrollTop;
! P- A1 ], x; Z+ P E$ j y- S }
# p9 I! B& T9 x8 I% X else if (document.layers) {# h' s0 P) H0 S6 G
document.layers["supertext"].left = xPos + pageXOffset;& z5 S. E P) U
document.layers["supertext"].top = yPos + pageYOffset;
% N3 Q7 d$ y4 C+ t4 b) Y }. O( I) T) ?- w( L" s' L. X. N6 y
animatetext=setTimeout('moveBall()',20);# z3 `( \8 s5 s# d1 g1 h6 T3 R* T
}
3 c! ~( Z& Z# u, Z- C0 J }5 {4 Q3 b" X. {+ a$ e! F' e: f0 E
- X1 r- k; N F
function calculatePosition() {
. A, F) E1 W9 r# Q5 {: J' U if (xDir == "right") {/ M& y! I$ v+ N& v
if (xPos > (xMax - contentWidth - BallSpeed)) {& {& ? s: g; p) F
xDir = "left";
) N) y2 e. x: q: b9 a }
) e% m) l/ s. y& R! p8 u% K7 Z }
8 x7 w! k+ _/ Y: K2 C) c h2 M else if (xDir == "left") {( Q3 V2 V, u+ ?9 D' e3 G
if (xPos < (0 + BallSpeed)) {
4 v; D+ ~' G( E" v$ o xDir = "right";* p- b u1 H1 K! e) R5 j4 H1 S
}+ k. m- N0 c, x m( v
}/ u; A6 y: s! @0 j0 Y0 p" b
if (yDir == "down") {, P& l, F9 P; D3 ?% x8 e e) |
if (yPos > (yMax - contentHeight - BallSpeed)) {
8 w; m+ U6 N) S# h, |: p yDir = "up";5 N4 R* _/ y7 Q2 D) t
}, U( d" W$ q- X) Y' c2 x8 e
}
( D2 \% [0 \9 G! i4 x else if (yDir == "up") {# k: R9 W& j$ E
if (yPos < (0 + BallSpeed)) {& m P0 P* J/ i+ E
yDir = "down";
5 z5 w- X9 x$ P) a$ k }
! _0 f3 l& A7 r z }& W) ^0 K2 D3 _" D
if (xDir == "right") {
! S( }' C) Q/ k+ n. K8 _: p5 m xPos = xPos + BallSpeed;
& l/ i( y i( S }
* p1 o6 R, P6 ?8 i; { else if (xDir == "left") {
4 K2 R: c( Y9 d }( ~ xPos = xPos - BallSpeed;
6 j# z1 V" w% t( J, L; H! R' S }
# @8 e' `# @$ G! i- W1 d9 W else {( P0 e3 N [* N
xPos = xPos;
2 _# v& k1 h, k/ f }
9 t4 `. _' R0 E' v if (yDir == "down") {; y5 G1 j5 N- U/ f. k# l
yPos = yPos + BallSpeed;
& t' E* E/ ^" {5 K8 a H' B# @ j }+ X& s7 U8 X7 p# t- _/ T
else if (yDir == "up") {0 B" W F( d0 x4 l" P1 H2 B' {- V
yPos = yPos - BallSpeed;- K& J4 `; V0 j( V: C" G
}
. m6 f6 V/ ]6 Q8 }. S else {6 X1 f3 @# e0 g3 S( c) }
yPos = yPos;
, H1 [2 T4 s! S }3 d. f' M+ V! [" }. M% o8 S
}
; i3 {0 `- S( V! Y4 X
$ B, P! x) A& I$ w8 Vfunction hidetext(){
- g" W s2 Q, K% k# ~( n! kif (document.all)6 u+ N* T: G K, `7 H
supertext.style.visibility="hidden"! E6 U ^, i, R% p1 ~: `
else if (document.layers)
$ X, B' i* ^) p% Rdocument.supertext.visibility="hide"
. X0 z+ `( @, }& e( mclearTimeout(animatetext)
) @4 H( Q- p. i}
3 |: ^$ o2 \. ~" d6 w5 V$ Q2 h9 d- _7 T% X, B% G
if (document.all||document.layers){
2 R* k* E' r1 r9 ]/ f& ^document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
E# H7 N8 Q. u- L- Kwindow.onload = initializeBall;
& W+ @) W; L6 R' q1 _2 K' c8 F( `9 f+ Lwindow.onresize = new Function("window.location.reload()");+ e3 M3 s- J0 g$ z" \, @
}
) ]. X% j- l* C" U" ^
0 l8 f2 V0 o i. h% [</script> |
|