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

|
网页之不断弹射的文字-特效
<style type="text/css">
& H1 q% j& r; ]#supertext {# h) P# E9 K4 f3 C
position:absolute;; ]+ n* w6 O& D' ]8 N+ D
left:0;
q1 d9 o, p; z# f# o- ^/ ptop:0;. P: i4 B6 c6 O! n- J: U* J
visibility:hide;$ q; U1 v- b- H
visibility:hidden;/ `; C/ l2 c" n: w" U: D1 ^
}
K' [" q) f: g! ?8 z</style>
9 D% M' l, G: L# }& ^" j<script language="JavaScript1.2">7 X3 n, s1 [: k; P5 Q n0 _
<!-- 改变下的字体的大小。颜色--># B. P1 z2 r5 X2 w, \
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
1 c0 t; v2 X: R2 G) V Jvar hidetimer='';
; q! P' Z- p5 l1 ?; V e0 M2 l<!-- 改变下的弹跳速度-->
4 I) |! O1 K8 i, E5 q% E- tvar BallSpeed = 20;
' n: p2 S" y |+ dvar contentWidth;) Y5 E+ w# ~1 K+ H! ]6 }! P! c
var contentHeight;
' ]2 @5 h$ e0 _' ?+ I" nvar maxBallSpeed = 50;
( X: \1 ~( B, B: @" O4 d5 q* Z$ J' Y8 m/ E Q4 F8 n; p% f) n
# y* r ^2 v1 c, O& B3 ~ e
var xMax;0 t( V- o8 c- s, C
var yMax;) n$ h9 U5 W& c4 W, n1 m4 t' \4 X
var xPos = 0;
; Y2 M) b. b: V2 y v- O Rvar yPos = 0;, r7 c; m9 H4 v% A' a" V
var xDir = 'right';/ [: ]3 v! q0 G/ k9 m
var yDir = 'down';
8 @# G; u, {* u% P, W# }' bvar superballRunning = true;# H2 i0 e& z* j& f# M+ G& O
var tempBallSpeed;
2 O2 G" c8 l2 I# Gvar currentBallSrc;2 h/ ]8 `2 x# x/ c
var newXDir;
+ [( L' m6 M# T7 w0 k2 A6 T Pvar newYDir;1 K4 ^9 n5 N6 Q9 @
6 T5 W% c/ @2 E# g/ }
function initializeBall() {
! ^: k2 P# D( v5 I6 Z if (document.all) {
1 e, V* |+ \) p& c( s. _" c xMax = document.body.clientWidth
, i* ^5 \$ m4 r! P3 D yMax = document.body.clientHeight
. P* A% ~1 i/ y" {: R( p document.all("supertext").style.visibility = "visible";; N) i4 d- F; W) X V' o% _
contentWidth=supertext.offsetWidth
& H: U6 C* q& n4 @/ o4 [ contentHeight=supertext.offsetHeight
* w: G4 m% C. \# o( l }/ F; {$ D: N& Z% O
else if (document.layers) {
% M( w3 [3 u% I" g% S# L6 F xMax = window.innerWidth;
( { L6 f* w; d3 ~ yMax = window.innerHeight;
2 R# e- V1 }; b6 y# i, S5 D/ Y7 h) ~ contentWidth=document.supertext.document.width- Z# f/ x+ Q2 `& L# L* ?' S
contentHeight=document.supertext.document.height' s% ?5 ]' t; w( \
document.layers["supertext"].visibility = "show";
" x3 }) X0 X! y0 j0 R; ] }
: T0 ?8 p9 P3 K4 z P( ~/ T setTimeout('moveBall()',400);/ M/ }0 @/ r a( e3 w+ K
if (hidetimer!='')* {+ [ C+ f4 E% p4 `. ?- U
setTimeout("hidetext()",hidetimer)+ u w1 i! y4 ^5 g2 j7 ^$ Z# _& A6 X
}1 `. T; s! n8 A8 p3 }& }. S) I
$ G5 h/ @# k: c& bfunction moveBall() {4 g8 a/ V" y; @, g! p+ S3 g
if (superballRunning == true) {
# a) ^* Q6 X1 B6 w0 A4 L5 Y calculatePosition();
/ @9 Z( K2 x9 Y% a if (document.all) {" }% K& i) v7 {
document.all("supertext").style.left = xPos + document.body.scrollLeft;; ?$ Z5 }4 ]- H1 p2 J" {
document.all("supertext").style.top = yPos + document.body.scrollTop;
$ M" q9 B! W8 o3 o4 Q) L* \; \# | }. N) _1 w8 r+ Q
else if (document.layers) {& z4 [# h) D6 c
document.layers["supertext"].left = xPos + pageXOffset;
/ e( I2 ]3 \) ~7 w document.layers["supertext"].top = yPos + pageYOffset;) ?4 `% P5 n5 r2 D2 f
}
N- c [; I0 p" o animatetext=setTimeout('moveBall()',20);
/ o) j' G i) g6 b$ z: r$ X9 ~' V }5 {* b3 k0 W+ P- A
}* X! L1 h$ X# Z l8 e: ~# A
/ A2 q/ X" S x/ b" r$ Q
function calculatePosition() {6 v. D; E3 L3 ^7 l
if (xDir == "right") {
, G# M' [ w6 X! `' b9 x if (xPos > (xMax - contentWidth - BallSpeed)) {
/ U& Y: p+ Q, X M) x6 P xDir = "left";
+ P) y; b3 G! E5 y. \; e; C }
3 ^6 m+ D* L3 ^3 {' i5 v$ M }
; A# ^& h+ g: o3 x) G2 a9 j else if (xDir == "left") {5 H; F# c% \& G4 j9 K$ ~
if (xPos < (0 + BallSpeed)) {
' G% \, K+ ?2 C: d- s; B6 ` xDir = "right";( T. x6 Q+ n# W3 b
}
C# e& O2 x; h6 j }
, V) B4 P* I9 _. W, A4 e/ Z/ g& { if (yDir == "down") {
J7 t. n0 M& @# L2 h" W if (yPos > (yMax - contentHeight - BallSpeed)) {
6 b6 I; R: L2 H: ^- U yDir = "up";6 o* T; Z' W7 A9 H& z
}
% ?* p% d$ V1 h1 K8 G3 E. d: N }( Q b, ?$ _- O% B: ^# `
else if (yDir == "up") {
' c: R2 v5 N( Q if (yPos < (0 + BallSpeed)) {
& e( h! Q' Y# |' S/ U7 ] yDir = "down";; B' }2 z( e3 e( i& o4 |0 H
}
5 m0 i, _; \$ v& K: H5 V+ i) K }
9 U8 W3 c% |# S9 }5 h1 Y if (xDir == "right") {
, Q5 Z" ~) Y5 W xPos = xPos + BallSpeed;
; D" m% ]7 P& F6 n }) z2 m; _9 f/ m; i P: e$ F' d
else if (xDir == "left") {( S1 H9 a7 r# B- W7 p8 A& K
xPos = xPos - BallSpeed;
) M9 a+ R# J- m" i }
. i2 {2 d$ o- ~: {+ Y: r else {. B2 t2 R7 a1 R& S
xPos = xPos;
! H6 ~2 Y. N, g$ O: ] }
% \& r! t; Y) E" A+ w# B" j8 B" P if (yDir == "down") {# ?5 x I0 ]' J
yPos = yPos + BallSpeed;
0 M! _! J2 i6 q9 n0 ^- P5 B, ~. L }- {: w4 `2 N# \7 J' N
else if (yDir == "up") {9 J4 z% H" ?6 x2 H9 _
yPos = yPos - BallSpeed;" n5 c6 k% R# a+ |! N' i+ k
}9 T7 d) u) y8 w* @
else {% u) M# m* k) G2 e. G$ x: `. _* {
yPos = yPos;
& {: }5 m' G; b) p2 ? }, m8 r! A: S3 p- R8 I2 V- ^
}8 `- K8 L: W5 s# u
- S" [- M& z3 c {/ z/ K# c/ cfunction hidetext(){7 ?- C2 a$ V! U+ f; W" k
if (document.all)
+ f. u' s! T$ E2 m/ ysupertext.style.visibility="hidden"' a8 @& ~5 A4 m/ o0 g
else if (document.layers)
4 l$ I7 R" R$ `+ F5 t! r9 Pdocument.supertext.visibility="hide"9 v2 `8 E. Z) Z- b% F! S0 }1 X
clearTimeout(animatetext)& L9 B4 N" L( t \5 a% L: u
}. v. ^! L0 f& E* q7 P
/ o8 E' h) Y0 R2 c! }. R" l
if (document.all||document.layers){
' e9 D g; `) v4 k7 x, L' Vdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')9 R; K% W" @/ v$ z t9 a
window.onload = initializeBall;
4 _; q# g9 |4 @window.onresize = new Function("window.location.reload()");4 g* ~8 B* G/ b) U a0 o6 x# y
}
- M$ r. }; p6 e$ J8 u) S$ ^; Q% J; H: z' z) W
</script> |
|