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

|
网页之不断弹射的文字-特效
<style type="text/css">. J; A2 }9 N; S5 y- T- G
#supertext {
$ K( @3 Z: x0 V9 ~% Hposition:absolute;6 U# q6 Q8 x) B! ?
left:0;, W' G$ I- a% O, o
top:0;
4 Y. e4 p2 M0 o( u3 C8 a( i7 Lvisibility:hide;7 F- i6 W* e" Z3 W7 h# G. b
visibility:hidden;- v) |+ t! |/ M* V7 c& M) D# ~
}0 F& y. D) w' s3 u! ?
</style>- f* i& `( Z! l/ [5 P3 Z1 H
<script language="JavaScript1.2">
: v( b( L; v: M+ M9 O3 }+ I2 \<!-- 改变下的字体的大小。颜色-->7 S: Q8 |! o+ w
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'. d, B w: ]9 K0 i; y- E; e
var hidetimer='';( n$ r% j4 D$ x- G- S
<!-- 改变下的弹跳速度--># e3 U2 g' b1 Z, P- g" H5 C2 p4 U
var BallSpeed = 20;
. r% i; x" n# |var contentWidth;
) @" S( z% s7 k0 A5 n- Ivar contentHeight;, S( Z+ A/ `3 N( \" o: Y
var maxBallSpeed = 50;. N8 x+ m+ Z1 a; G. i, s
3 L% K4 J2 y' s" R U2 T) y
4 s" _ d; L6 p" G* _7 P" Z' X4 Dvar xMax;
- e& d+ ?1 h$ A, j8 H7 B! zvar yMax;- Q! Y; \% \1 n. \5 X$ |
var xPos = 0;
4 x3 K6 y% h8 J! z- ~! D+ q" }var yPos = 0;* h$ y4 G# |: F/ g: f' U
var xDir = 'right';+ b# V% p6 P& J
var yDir = 'down';9 h3 K1 A1 @7 R* k+ p) W* P1 @5 L
var superballRunning = true;
3 E/ _. b' k2 c5 D% Tvar tempBallSpeed;, Q ?4 X$ t0 L# v" T
var currentBallSrc;
. O R" F! e8 b8 u! j8 ovar newXDir;$ ]! {7 K& C+ y4 K3 W7 z6 y
var newYDir;
3 E* j i2 x$ J) A: m
; M/ Y; y/ D& ?% L* Pfunction initializeBall() {# f% i9 T% M- `' ~: \
if (document.all) {$ A5 o$ C" x( l2 u. Q; l: y1 I
xMax = document.body.clientWidth
! N5 R4 L w( d/ X' E) G yMax = document.body.clientHeight# a6 S q& @2 e- k' h2 b7 i2 J
document.all("supertext").style.visibility = "visible";
o- w9 [+ B! s& F( G4 K contentWidth=supertext.offsetWidth2 W0 @1 \! N; l! Q* ?
contentHeight=supertext.offsetHeight
( e/ v, O$ w' N2 q4 c }' N! V: f/ N0 K2 B3 S* G- |
else if (document.layers) {
" y& K# k! l" J, h3 n xMax = window.innerWidth;
% v1 H* g3 c4 O) }1 B# e yMax = window.innerHeight;3 J$ C! @8 W; `' p& P. _1 y
contentWidth=document.supertext.document.width
7 a2 d" g/ h; @1 r contentHeight=document.supertext.document.height
% |2 V! ]' T3 u% t5 q7 d* d; \3 I2 X% C document.layers["supertext"].visibility = "show";
7 K+ w# B5 K4 U% ^2 h. n( p0 s }
# {1 M) G' C$ Q& P- A setTimeout('moveBall()',400);* F( d8 Z1 a1 T5 ]4 Q+ A
if (hidetimer!='')0 a" s: Z; L: d& J- ~! n4 _
setTimeout("hidetext()",hidetimer)% R/ _/ i. ?; u! H- }+ J v0 ^1 R
}6 _& S$ G+ G; D8 F
1 N" A- f2 a; _+ V! H$ @
function moveBall() { A# K. |: f" n2 P8 A3 r. [
if (superballRunning == true) {6 _5 c G, o; P! Z; E9 s( G
calculatePosition();
% L3 t5 [+ i( P* ~+ F if (document.all) {1 o" F& D" N T2 |- f5 r5 A8 f; F
document.all("supertext").style.left = xPos + document.body.scrollLeft;) [) T6 E* D. l) l2 g5 P7 Y+ o2 c( z
document.all("supertext").style.top = yPos + document.body.scrollTop;
. U( @: u3 u% V( Y }
; I8 N1 V7 E; Q% q% ]/ R8 n else if (document.layers) {! n/ i- C; |) U8 r) n( P. t
document.layers["supertext"].left = xPos + pageXOffset;
- }" l$ ? E# Y4 A3 F document.layers["supertext"].top = yPos + pageYOffset;# K4 A" L* l9 Q: }- Q# B
}2 S& O7 i- o2 x6 X5 [4 V y
animatetext=setTimeout('moveBall()',20);& r. K8 B. d& { f9 b+ z R
}5 `0 ?# C# f# ]) S& \4 u: g3 W: B" o$ R
}9 r4 o- V( N3 j' x, U# c7 y/ ?
# s2 k( @& D& F+ a' Mfunction calculatePosition() {
) r- j1 g) m- K9 t( ^ if (xDir == "right") {
1 v3 E5 Q! v2 U+ K% B/ Y( h) _- D if (xPos > (xMax - contentWidth - BallSpeed)) {
8 x' _8 T4 B$ F# B+ A& [ xDir = "left";# D9 h2 q6 W; H+ ~9 n3 e
}
7 i7 Z2 d% y* {" M8 l! Q4 {4 t }( `1 w! I K# y8 x7 {& T
else if (xDir == "left") {2 N* Z9 O1 A/ K9 M$ v! {! b
if (xPos < (0 + BallSpeed)) {8 g- h! X0 q! T! }
xDir = "right";$ M8 e. p3 z( [0 p( P
}
7 k+ Q* E4 Q- |* g2 O }0 X# l1 R) y2 ]3 ]. |6 Y2 a5 ?
if (yDir == "down") {8 m) T& `- P! Z& ~% e7 I, m
if (yPos > (yMax - contentHeight - BallSpeed)) {; N/ h g" y1 c% R) E8 k. g: e
yDir = "up";# N' W+ D/ ~, b. K8 m
}9 Q# s6 ]% L6 w, P8 ^
}+ x4 d9 v; s1 }5 J+ O
else if (yDir == "up") {
, Z- R1 u# p, a+ ~) O& v2 \; ` if (yPos < (0 + BallSpeed)) {
+ K0 d# K1 @3 M: `- q, o yDir = "down";5 v4 I N8 ?- b6 X2 o
}
4 {' l- f2 ~* z$ L; S$ y }, L8 x/ q1 u3 l) g
if (xDir == "right") {0 }5 G3 K/ D8 Y; y C% o& J; W
xPos = xPos + BallSpeed;9 [& z9 V2 `6 \7 e+ e4 ~
}
: R6 t1 G: f \7 r else if (xDir == "left") {
% l! y5 ]1 k% [ O xPos = xPos - BallSpeed;
" E8 V9 G2 A& w- q5 ~ }
+ d8 {! T- S: Y/ r else {) \0 r% g/ V% _, f2 s
xPos = xPos; J% {! P) U6 F1 h+ O
}9 ]' T7 p3 Y# X' W$ C
if (yDir == "down") {
. d/ c9 e5 c" \: N8 }; f# s9 u yPos = yPos + BallSpeed;# A, P' v1 M- R9 x' }( t2 M
}
, D( j# z* u7 H. C3 p0 m$ F else if (yDir == "up") {
; c& ?5 n4 d1 E yPos = yPos - BallSpeed;6 ~5 t" U6 u( i/ F3 J" y" a6 `
}0 `- `$ P9 l& ~- n
else {) F. M' _9 j8 x9 y
yPos = yPos;( F) D$ B* y1 a1 h* C
}7 g; D. w' t' z" M9 t: Q
}; D1 T& T6 l1 v' K1 w' r7 P
/ r( c1 e, C7 h ^" Y# N4 s
function hidetext(){
- C2 }- L" w/ ]6 mif (document.all)
- V& a# C& t' _supertext.style.visibility="hidden"; W6 _) A# K) S# H, g) C( V
else if (document.layers)
( o! }8 v% b S+ A0 f4 r8 Hdocument.supertext.visibility="hide"
) k: B$ t! z% ^) n4 oclearTimeout(animatetext)
! u" ]3 I$ q& Z8 I& x}
4 ?' i5 @. C! a4 V, q W( p8 t1 I$ K: @
if (document.all||document.layers){
* }: s4 \, i# `. n6 [document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')/ o' w9 V; z) M
window.onload = initializeBall;& c: ~- @' `6 |
window.onresize = new Function("window.location.reload()");+ _6 S8 C% v/ l5 F0 u' X- P8 p3 W
}' L: c1 v5 z! e9 ^
+ w L6 p+ A* T) y4 k$ T7 M
</script> |
|