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

|
网页之不断弹射的文字-特效
<style type="text/css">7 r4 j9 m" W, l: z. K
#supertext {( @) q6 g% L6 V" |& D
position:absolute;9 l5 x$ @- ~/ H4 a
left:0;
) a+ W- B0 T. rtop:0;/ l( g# j$ T3 |# O7 l
visibility:hide;, J4 e0 D, T# q% J
visibility:hidden;
4 ~( F; R, T: T4 e}8 P: ? R2 U$ r0 }) ^ C
</style>
' [ _1 D) s. y. s( Z& v0 k" R5 g<script language="JavaScript1.2">" ? U- N8 }( u4 l
<!-- 改变下的字体的大小。颜色-->
; o; O2 Q3 [0 r/ S( [var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'! v u& `! q( f$ C
var hidetimer='';5 K5 L* p6 o2 L8 W
<!-- 改变下的弹跳速度-->
7 o' x$ ]- G- K1 T# rvar BallSpeed = 20;
3 _2 \/ [7 g( p! x% R7 ~9 |var contentWidth;
9 l/ K t) Q* K' F% C6 Y; Y7 Q/ D: ~var contentHeight;
4 \. ~( S; y& U' P5 I1 N! Qvar maxBallSpeed = 50;, V. A2 d8 b# ~
$ ?' W1 Y5 g% [0 f* i$ |' R/ v& e- i l1 }6 u5 E
var xMax;
1 Q. M3 ?2 P. j y3 ^1 d3 hvar yMax;$ V! d3 Q4 B! z0 t) D
var xPos = 0;, f- S! k4 ~$ k' S v
var yPos = 0;
* |2 |6 L: L; b d* S) nvar xDir = 'right';: g) ]% e3 T. Y# V L: |9 K0 q
var yDir = 'down';) V6 G" D9 l3 U# K8 h5 \
var superballRunning = true;
* ~4 {: s# P2 @var tempBallSpeed;
- ~1 _8 G5 @5 s/ ivar currentBallSrc;0 [; \2 J u: H2 _
var newXDir;
5 |/ B0 t; ]0 F2 ` n, h" Evar newYDir;
2 h' J! K3 C/ p% n! c# b5 c
! p% Q9 ?7 L Y/ pfunction initializeBall() {, ?. `) f" Q: Z/ H! P# ^# b. g
if (document.all) { I" l+ N) ?3 A/ D$ i7 c/ [
xMax = document.body.clientWidth+ x( E$ s" J3 t3 H1 C1 A& Y
yMax = document.body.clientHeight+ c9 L7 H; `* h/ `, f9 O% b; S% e# n
document.all("supertext").style.visibility = "visible";( J$ j: ?# [/ r! K A9 r
contentWidth=supertext.offsetWidth
: a3 K9 u9 b4 \# n; g" @4 v3 X" `0 w contentHeight=supertext.offsetHeight
* K4 { ?% H" S3 m6 B$ U; k; B4 o }* `: \# U1 W$ R! R8 S. p/ d6 v: F' q
else if (document.layers) {; y4 E9 b8 m; V* V* h
xMax = window.innerWidth;
3 d$ R8 q( o/ m9 M yMax = window.innerHeight;
Q( c+ S3 U$ q4 P7 `/ T0 k2 e) \5 | contentWidth=document.supertext.document.width
9 l2 |6 h" q" Y# h1 [ contentHeight=document.supertext.document.height
N, o* D; `* W5 [4 y3 V: j document.layers["supertext"].visibility = "show";
# d! s i b0 R- e9 {/ _ }: a0 a7 B5 q- M
setTimeout('moveBall()',400);, J4 a. F- G2 r* L/ ^9 u
if (hidetimer!='')* L# W" p" l- e) V1 ?
setTimeout("hidetext()",hidetimer), Q9 g) ~! }: v$ P
}
! n" E+ V$ J: ^5 e. H6 p( f5 d2 `7 m% V- {
function moveBall() {
8 \" Q9 t6 ], t7 C3 D if (superballRunning == true) {, X! i: k; l( Q9 w2 D. b! i$ C: ?
calculatePosition();- r( ^4 ]4 T, ~1 l
if (document.all) {% a! U* F9 X+ |: H4 ^" T
document.all("supertext").style.left = xPos + document.body.scrollLeft;
2 S5 w4 Q+ h& j8 H; d document.all("supertext").style.top = yPos + document.body.scrollTop;0 Q7 X; N$ _9 g0 R" |. B, n& {
}5 w: N* Z8 k7 I( |* w# r) g
else if (document.layers) {
7 |5 T- a2 m" J# A/ ?& d document.layers["supertext"].left = xPos + pageXOffset; P5 N/ L( U1 {
document.layers["supertext"].top = yPos + pageYOffset;- s* W+ U: N+ C
}+ r8 ?1 r+ F5 ?4 e& }$ o
animatetext=setTimeout('moveBall()',20);! o; t }+ p8 W% A$ D" E
}
' l4 R" a, J8 I8 v9 X1 \( G }1 H5 s. j+ ^$ S. I" j
7 N, o) U/ H$ Ifunction calculatePosition() {
* Z/ S. F2 U) d# u2 U if (xDir == "right") {
$ e" w7 H- E6 U3 ~) [" | if (xPos > (xMax - contentWidth - BallSpeed)) {. L" u' L' ]: T+ Z+ `
xDir = "left";
, M' b& g8 p9 N! f" C }
( D! P- ~* `8 l" N% P4 Q& @ }
" [* s/ Q s! r$ a else if (xDir == "left") {% K6 k) d9 f4 n3 F
if (xPos < (0 + BallSpeed)) {
1 Q/ _+ _/ S6 {& L3 ~& K) \0 O xDir = "right";
5 I9 Y' Z; d( M: m% o }' x* w. {/ q( R8 ]% r& b! Q
}
" k, e8 W j# `5 X) J; w0 i if (yDir == "down") { b: I% b5 q5 }
if (yPos > (yMax - contentHeight - BallSpeed)) {4 y& x, q" l h! `) D$ z5 E/ H6 m
yDir = "up";) L1 L; f1 }! B4 K% g- e* H# D# ^
}9 h8 |# @+ e1 z
}
% T, l9 }7 l+ H5 P) W- ~. G/ J else if (yDir == "up") {
$ {6 W/ O' z: e6 l6 } if (yPos < (0 + BallSpeed)) {
- a) x3 W2 y3 W8 X1 X) h yDir = "down";
1 f/ ?. ~# N- d+ M- r }9 [+ k w2 `8 `9 O& N1 h5 l
}" V, h& V$ N1 a k% W
if (xDir == "right") {4 D8 s5 e* Y3 }* P
xPos = xPos + BallSpeed;. H' G0 z$ o3 h% P1 ?7 h: V: O
}* D" M- l5 F# y; m# O; ]
else if (xDir == "left") {2 X. n, X% p9 O
xPos = xPos - BallSpeed;
; {9 {7 b2 V. U }; h) \5 b- ~9 e6 _( `! Z" Y
else {
, ?5 L3 t+ L: n xPos = xPos;' o( z* a% Q& k; D
}; v/ y3 O# I+ E. E2 \, w9 ~4 ~
if (yDir == "down") {
2 t7 E a3 y8 C" `$ {4 k" C; s yPos = yPos + BallSpeed;5 d; W: b7 Y2 [( w3 g
}' M+ d5 P, d' A% {! r7 o" P- n
else if (yDir == "up") {9 ~$ ?) r H( f- |
yPos = yPos - BallSpeed;
- y, L9 U; ~2 s% p- ~ }
4 m* ~' M) L; I0 {9 q. A: u0 T else { S9 Z! p% U: R, V! ^
yPos = yPos;
6 O7 z1 R% |. P% n }% M* d D! O4 o8 @) v4 _
}2 T3 f7 C% o9 R
" o1 H0 z0 v( q
function hidetext(){" Q5 a2 m$ \% g0 I" W
if (document.all)& L$ C& b7 V+ {1 [+ Y/ q. P
supertext.style.visibility="hidden"9 L& g5 t$ b8 p
else if (document.layers)
$ O/ G q8 L$ y. [/ Adocument.supertext.visibility="hide"4 W% [3 o% M4 O; V% `5 S
clearTimeout(animatetext)4 {% e8 i. [& G& l/ u
}1 z: }! X: C7 n2 z/ ~2 p$ D
7 z% V$ e# G& Z ]6 ]1 v
if (document.all||document.layers){
! J1 t' ]/ b9 h, z7 v( Mdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
9 Y- i* ~" t% v1 X) F* qwindow.onload = initializeBall;& W& B) J# B; v: ^, s- {
window.onresize = new Function("window.location.reload()");+ ]( e) Q. {" @; j
}
" P6 v; e3 a0 D! T. c% D
: o9 O3 T% Q; A6 x8 [; V</script> |
|