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

|
网页之不断弹射的文字-特效
<style type="text/css">3 k- \8 O+ B' \
#supertext {
+ e2 r& j3 F! l8 ]/ R; Q6 M* ]position:absolute;& ]+ V. n9 O5 v
left:0;0 ?# f: R+ f5 \! R
top:0;
) v5 p; T( T! M+ fvisibility:hide;
- ~) D# G# T: ^visibility:hidden;) o$ r: H* f- C+ m
}
# Q% d" O3 q+ y3 s6 R! Z* A6 F( v</style>
: @4 P. O' m0 C( E<script language="JavaScript1.2">
" d1 B; a7 a" `1 g7 f<!-- 改变下的字体的大小。颜色-->
2 G* R2 l5 s& c$ T$ W( xvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
' Y% ^; U" f# z+ m% x' {var hidetimer='';
& B9 `- y3 [, R- H0 L<!-- 改变下的弹跳速度-->
* B# \ Q z% Y& U7 }var BallSpeed = 20;
: J; P7 D. i' l9 P) ?6 {( Kvar contentWidth;$ }; S6 Q+ E% Z. P u& J: N
var contentHeight;/ S7 v8 j0 S3 p$ n/ W& `
var maxBallSpeed = 50;
5 B; E. S/ c6 w- G5 M6 V$ w' Y) h: Q5 c7 h
' l! \0 k' {1 g+ |7 ^$ b8 l* F; xvar xMax;/ T$ t% i- A' ^
var yMax;. w3 l* ~- @! a# W3 _! s, Y# d: u
var xPos = 0; b4 D0 L/ p) @2 Q0 A+ f
var yPos = 0;
7 }; Y: [% m8 `. U& c6 h! M4 S4 Mvar xDir = 'right';
, X: G, o6 N( O0 w2 R j$ Bvar yDir = 'down';; f7 O( _% y3 u
var superballRunning = true; K4 i9 N, ?0 E, m8 P
var tempBallSpeed;
7 N$ p6 Y1 u% @6 ~5 B6 z( H+ pvar currentBallSrc;
8 b0 s& V/ ]2 ^' h% Z6 K% P6 yvar newXDir;: Y) f( P. O( f0 q# u: {1 @
var newYDir;- `0 F& f( a5 V2 P$ ~! z, Q1 @
; S; u+ W% X- d( I$ u' A @
function initializeBall() { u/ { l6 G1 D" x) }9 m
if (document.all) {
5 L9 I6 d" v9 z" k xMax = document.body.clientWidth' @6 o% b8 X2 x8 i7 v4 O
yMax = document.body.clientHeight
# r$ B7 \9 V; W7 y' q" v document.all("supertext").style.visibility = "visible";
8 E* v8 @. v6 s$ g* ` contentWidth=supertext.offsetWidth
2 {9 T# l- y$ C# F% H2 w contentHeight=supertext.offsetHeight7 V; k3 A; X5 T) f+ S3 I6 E
}! F4 U& ?) }8 K: f4 P) ]
else if (document.layers) {
$ j" w' a2 D0 B# _7 [" d xMax = window.innerWidth;
! W7 W" ` S* T4 G" q yMax = window.innerHeight;+ Z6 \7 {! R; H+ E; w$ [
contentWidth=document.supertext.document.width
# ^- c& W3 I. _# H contentHeight=document.supertext.document.height
' V3 M8 ~' T: ~4 K- J; X$ [ document.layers["supertext"].visibility = "show";* r- D( \" m) a* A' b0 I
}
1 A* N, V8 z# F- a7 ?! v* p setTimeout('moveBall()',400);
$ A7 L: K5 M: K7 o% o/ L if (hidetimer!='')" C! {# ]8 u/ A/ K9 b% u H
setTimeout("hidetext()",hidetimer)/ O8 n& C" K# f( Y. J+ _8 R
}7 p$ } f5 Q% | W
4 B+ S2 u v$ [2 P/ Vfunction moveBall() {6 s/ \* c: H1 h. i! k; p
if (superballRunning == true) {
4 ^/ A c+ }% A/ A calculatePosition();6 i, M2 X5 ]0 U# K4 E1 v
if (document.all) { N8 J1 g- i/ g T1 l; b5 e
document.all("supertext").style.left = xPos + document.body.scrollLeft;
: y! ~- I& ^( R& m3 G2 Y document.all("supertext").style.top = yPos + document.body.scrollTop;) ?2 e- W J% }% y) j" Y: c
}
" i' \. `) u8 ~ else if (document.layers) {. z: Q6 S- }$ M+ d: j# j. Y
document.layers["supertext"].left = xPos + pageXOffset;$ u d5 ^! w6 O$ M& a6 i
document.layers["supertext"].top = yPos + pageYOffset;( Y2 L& Y% a8 e0 S5 w V- R: J
}
0 V- ?2 I7 c' Y8 Y" y animatetext=setTimeout('moveBall()',20);
' b: B9 f# w2 G' v2 Q* @) ~& m( B }- b! K6 K5 n+ } {8 f0 k( T9 c
}
2 m4 R% h3 |: r7 Z; k" [7 L* k) n$ L8 ~1 `9 [+ v
function calculatePosition() {+ t9 `$ I# u/ c' a9 f/ F0 q8 w7 b+ e
if (xDir == "right") {
& ~) ?! g- |+ t7 E M' F* t if (xPos > (xMax - contentWidth - BallSpeed)) {
* a6 E' `" |2 `) Q2 q7 V k xDir = "left";
$ j( O0 E% H5 Z8 m2 e- P* x4 M }! ?9 A t, U: u
}
( Z7 a1 Z0 ]0 z; c' r else if (xDir == "left") {* n& ~7 S, q7 i
if (xPos < (0 + BallSpeed)) {
9 C7 m( x* ~/ y3 J( a1 O* X xDir = "right";; O6 }( I$ X8 z6 |
}
9 l1 b9 ^4 x% @" o+ h( J2 U }; L: [2 x! e5 c) V9 x
if (yDir == "down") {
- f# I$ e9 u6 ?1 V0 L! F% _ if (yPos > (yMax - contentHeight - BallSpeed)) {
, U, s2 C# A1 p4 [7 A! A yDir = "up";% V% M2 S; ]- g( _7 n
}
) {3 Q2 i: F7 X5 N1 ?$ v2 c; i }
3 s6 D1 \' I9 n6 ~" C- O1 o; E else if (yDir == "up") {
6 z1 l+ \* ]9 Q* N& \4 U if (yPos < (0 + BallSpeed)) {
- Y' a* y) y+ {1 o# e0 ^# D yDir = "down";
1 u) ?: k$ Y" d( g3 P8 G }
( x G$ R+ ^' \# F0 U }
7 j' q( g& b2 N% {# T6 } if (xDir == "right") {
3 y2 g) r9 Z% ], h xPos = xPos + BallSpeed;
; U7 `0 c1 c" I4 q3 g }+ D. B: m% w# y' P9 ^4 }& `
else if (xDir == "left") {
1 A/ ^2 r: Z- r2 H* s xPos = xPos - BallSpeed;
5 u+ L& Q M8 C$ N1 T- L4 O } a9 @6 m+ T5 L8 ?
else {- G4 w4 T! U5 S4 F
xPos = xPos;: X2 |" i) a7 \' u+ a
}
" ~9 J" L1 r: F m, R& } if (yDir == "down") {* Y9 y( g1 f+ @ p* T) F7 I* Y
yPos = yPos + BallSpeed;
) w. A" x9 N, `% c* N$ U* h( A, ~! q }; `6 U7 J* q1 j+ u, g/ {" \. V& y2 ^
else if (yDir == "up") {
' b; u' }- |% E yPos = yPos - BallSpeed; b- u3 b; ~! r/ |$ o
}
6 @$ _" r+ a3 D# Q9 G6 R else {
" O: p z% e' K8 Y1 _8 ` yPos = yPos;
# j5 J. ^/ M0 U }' {4 r* W0 ^4 T2 M! O% S
}/ p5 \' V7 F# l$ P8 v( L" z
" z! ?8 L- {# m7 l/ N/ @8 g f$ n* x
function hidetext(){
8 V& j0 K/ ]/ ^& Yif (document.all)7 V4 F7 w c* f/ J, G4 R
supertext.style.visibility="hidden"
" B/ `% U& v' s9 v) J8 `else if (document.layers)
5 K# N a' z+ L4 _+ k" ]document.supertext.visibility="hide"6 w8 z* i/ Z- M4 p0 c" ~- z
clearTimeout(animatetext)
& B, k* V0 e6 C' J3 `; [}8 P. ]. X+ {5 H
" n/ Y# \/ J. U+ n M
if (document.all||document.layers){
7 f- m! Y. Y4 F6 odocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')7 M9 f h! D7 d: H
window.onload = initializeBall;
' u' U' @. U! }" U6 h6 [window.onresize = new Function("window.location.reload()");# V* x% F! F5 m2 k. m( ~
}
, P0 g2 D* x5 m5 ?( o$ i- W/ b( Y# ^+ U0 X
</script> |
|