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

|
网页之不断弹射的文字-特效
<style type="text/css">
! s5 T" F; G2 V1 [8 f! C" E#supertext {& B3 ^$ o8 B: f
position:absolute;: B9 P% x+ c) Z. q
left:0;
7 [8 D, u" r) V- t ~) K* g2 D- c2 u' mtop:0;
, |' v" q3 K, y6 p7 a1 ^$ e" ^2 S/ @+ ]visibility:hide;6 M, c6 m5 x+ j) f$ B: o/ I- e1 O
visibility:hidden;9 r- s8 A5 N% J( f- z' t8 T
}6 B o- ] ]+ s: K0 W4 p
</style>
6 c6 N$ a( ~. E0 W<script language="JavaScript1.2">
% @. @- Z" i/ P+ v! @1 X' o<!-- 改变下的字体的大小。颜色-->
; n: _* p% U0 C4 G0 Q% t2 @. qvar thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
! w% R$ K" H" p) e4 Fvar hidetimer='';
% g% d$ O9 w. ]! s( q<!-- 改变下的弹跳速度-->
9 F) J, P5 o% l0 C7 E) Kvar BallSpeed = 20;
/ k% ?+ K: n1 h1 e x5 w0 {var contentWidth;9 @6 {+ M; F2 S8 _
var contentHeight;7 k# ^, x" Q# A5 Q- W
var maxBallSpeed = 50;3 S M( J) _4 | |2 R' G
* i L3 f, U' o3 E0 b9 \, d3 y! K
* I: s! X5 I, v$ ~var xMax;
, r, p# l6 w, \ w2 K8 b5 @$ B- ?var yMax;; k* N6 S3 `" w6 ~7 |2 A! ~
var xPos = 0;0 ^. o# I# u9 j0 U
var yPos = 0;. a% X) ?# m! {! d7 O U, n% `& p
var xDir = 'right';6 e) i0 x) V/ B& Z; a
var yDir = 'down';! w- D6 W% O3 i1 E+ S/ ?, G
var superballRunning = true;5 ~0 Q' q" v6 }% x- U( b# X
var tempBallSpeed; ^& F" L6 ^* Z) k3 ?1 ]
var currentBallSrc;0 w8 W; @. ^6 M6 s
var newXDir;2 k+ y Z% Y9 C8 X- U* `. s
var newYDir;/ X/ m7 s8 a8 N S' c2 h/ H" `
% @; W( R# T7 x( w) u7 x; s" ?
function initializeBall() {
- ~+ W3 u% c3 L if (document.all) {
: r$ d6 ~7 V K+ b7 J xMax = document.body.clientWidth
# o( a! {. z. k: w4 A B yMax = document.body.clientHeight' `# S! t& N# d% X1 O& Q! W$ w
document.all("supertext").style.visibility = "visible";8 z2 K- Y# T$ w; E
contentWidth=supertext.offsetWidth$ T0 `# h! E% c2 U$ y! m/ V
contentHeight=supertext.offsetHeight
( I2 w E+ v, ^' s }" a- s; t5 _) z) O! p: G
else if (document.layers) {4 x" _. @2 D% d' A4 d, b+ f
xMax = window.innerWidth;
1 Q2 F. X0 \. @+ B& P2 c yMax = window.innerHeight;8 ~+ J7 U! h, f/ B9 B
contentWidth=document.supertext.document.width
# K8 t8 R! F1 E3 K: D contentHeight=document.supertext.document.height" j: ^; R. ?1 f) s" J5 _' T. I
document.layers["supertext"].visibility = "show";5 l# X2 b: W5 Y" k6 R
}& W( m/ r' m/ v/ t- ]
setTimeout('moveBall()',400);, H$ e+ u' e( A) m1 ?- X" y# o
if (hidetimer!=''), F& n' F) |; Y
setTimeout("hidetext()",hidetimer)
$ T$ A) [; u0 _5 `( o7 w }
: @( M' D% u+ L1 l9 e% s
1 B' C' `# A/ u+ o" b' z1 Jfunction moveBall() {
7 e4 b8 N6 o. W n* V2 `! T if (superballRunning == true) {( E l0 w4 M8 u0 X8 M7 |' c
calculatePosition();
8 n' Q+ _+ K; b9 ?1 O" Q6 j5 O if (document.all) {* s! d K3 H* `) {: |, r$ ?2 E
document.all("supertext").style.left = xPos + document.body.scrollLeft;3 c+ N/ F+ v+ c
document.all("supertext").style.top = yPos + document.body.scrollTop;
1 Q8 S: M# k5 k. x8 m2 a }( k/ O% c0 _) T- y: z) z
else if (document.layers) {
8 q7 s& F j$ h2 F/ c; A: i document.layers["supertext"].left = xPos + pageXOffset;) ]* {* V3 F" M8 C" x
document.layers["supertext"].top = yPos + pageYOffset;3 s' |; j7 n4 T
}
8 d5 S, U% L& Z2 E3 ]' X animatetext=setTimeout('moveBall()',20);
2 p0 \! q7 F/ D \3 P& a }3 }# r8 w' [' @ Y+ A( X% @
}
, x D8 K# J4 B! u' z. u& e+ G+ @, u9 @" _3 m% L, O
function calculatePosition() {
k+ Q7 |3 Z- f: T4 V6 H7 G if (xDir == "right") {1 P$ n9 P# g, [9 w! C
if (xPos > (xMax - contentWidth - BallSpeed)) {
7 j2 l- i4 n8 r/ L9 g xDir = "left";
" Q: X0 g: p% t- ^+ L4 Q$ J) t/ H }+ X3 J) O5 j% d3 Q
}9 q/ \" E; a! d- C- I
else if (xDir == "left") {
+ S4 ?% G( S/ f6 N, }! }. Z) P if (xPos < (0 + BallSpeed)) {
0 G2 e% [1 ]% w xDir = "right";
/ p& X( {" Y8 @. e$ a }
4 \5 R; f, T- M/ ^" |- P }
9 z0 `, Z+ T! q1 g+ \ if (yDir == "down") {) ?/ c$ s/ H9 U- H9 P4 h5 ], ~
if (yPos > (yMax - contentHeight - BallSpeed)) {: n1 f: w; _% x0 c0 z/ u6 J
yDir = "up";
2 { e5 {0 X) R* T } | t/ N' |* Q9 A% N
}; T6 Y& \+ |; |
else if (yDir == "up") {
( v1 N' E; ? _ F4 q: O7 k, g if (yPos < (0 + BallSpeed)) {
' v% {# n$ s& ]. a- y yDir = "down";) s e. {3 w/ D7 J7 o, u# i- ^
}7 H+ S; K! o8 _; S9 G
}1 B$ z' A, T' F- F4 |! S$ B
if (xDir == "right") {
7 W# _ S8 ` P1 J: C- g. ~ xPos = xPos + BallSpeed;! K+ ?2 W, P- H3 p8 c
}, g+ n0 _" k0 t& m. R7 T0 s) i, d' _
else if (xDir == "left") {
* V" ?& j1 {6 c" P" @: Z5 { xPos = xPos - BallSpeed;
9 ]; G& Z& S7 i& N5 x& M }
( K$ _" m( @1 W$ G# r0 ]4 O else {
- j8 }8 ~% e1 x& q7 S8 n3 ^ xPos = xPos;& ^, U7 |6 e& i4 e: u! F( h5 m
}
9 K6 H c- B: h6 | if (yDir == "down") {
2 u/ i! x- h" R( Z) K yPos = yPos + BallSpeed;
3 x E+ Z- ~8 s1 m }# [8 j. S0 a( E8 Z7 P
else if (yDir == "up") {. U4 p M- r, q9 j/ y' T2 C O
yPos = yPos - BallSpeed;8 K$ e K- h1 X0 Y6 }
}
6 [# ?* e0 n \$ B' w else {
1 _/ `1 X2 G5 y' r yPos = yPos;* ~7 p M1 U; M* G: k1 o7 e
}6 a! P# @+ ^4 z* P
}
* ~+ O) k5 E' P/ C r1 [" }2 ?; t6 C& o1 y$ |
function hidetext(){- F6 w8 C f8 x; z/ V& B
if (document.all)
, R# Z( o$ m& n+ d- ~supertext.style.visibility="hidden"2 s9 w+ p: c+ a' U
else if (document.layers)
, G8 P6 G! u/ ~0 ^document.supertext.visibility="hide"
c; [# v! x& K- ~/ `clearTimeout(animatetext)
5 l6 | L5 R3 Z6 p& P% j}: @9 i: O& |' a1 M& `: j
+ J7 l9 c- k3 M: i$ D
if (document.all||document.layers){& W% p* U8 A* Z0 h! J
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
4 `3 o$ R3 x8 g3 a, z! Swindow.onload = initializeBall;
; [- w9 T- M1 ~window.onresize = new Function("window.location.reload()");
& f8 c; S3 C% Z- r# q; c}
* h, N6 X4 b0 O, X( I
/ r# i- W5 k, O x: S4 m# O0 e</script> |
|