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

|
网页之不断弹射的文字-特效
<style type="text/css">
( @( v8 @+ P. F& h. U- p" a#supertext {
) I3 N3 S* u; A5 \2 Eposition:absolute;' x4 Z. e& Y9 n8 ~2 d
left:0; }4 c5 U( I) P8 F
top:0;
' C, x: v) {2 L" z$ evisibility:hide;. Y9 U5 l! I1 B5 ?
visibility:hidden;1 d+ B, \- p9 A
} H* B$ h: a- w9 I* f( n* G& D
</style>5 ~7 K* M8 K0 z7 i0 \
<script language="JavaScript1.2">' X# @! d0 S( C* X0 a5 [; ]
<!-- 改变下的字体的大小。颜色-->! Y* e2 Z0 \* f n3 s O$ Z
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
" \ v) m' g: L2 L/ lvar hidetimer='';8 O* G; u9 Q9 t; `' p
<!-- 改变下的弹跳速度-->$ w, p' @: F# | z1 E1 D3 b# u5 Q
var BallSpeed = 20;% R, q3 u# Q1 d3 U# E
var contentWidth;1 k _# k3 v4 n- ^: l
var contentHeight;* v; H( O" a$ j: W1 T
var maxBallSpeed = 50;9 w: l( d6 O9 G- w7 ?% X
/ `# i( n: ~7 b0 r [
1 [; K3 F! H( N6 M4 V" Q
var xMax;
( L6 u& Q8 O$ z- P4 J( Kvar yMax;
+ h. d9 a. \4 a; q4 g1 `var xPos = 0;* u! {/ L, H8 d; s9 j: J
var yPos = 0;
3 v( |( \, [- O! l8 J2 c# Jvar xDir = 'right';
6 X+ d4 Y5 G3 _$ b1 z" d4 Pvar yDir = 'down';
- { Y( ^6 T: h/ O7 w. M$ Ovar superballRunning = true;: O9 B+ Z: r6 b) H
var tempBallSpeed;' E: N$ x5 f& a3 f( A( N5 T. J
var currentBallSrc;8 b/ u" D" r! @. l n; p
var newXDir;3 f7 m2 ], W0 R
var newYDir;
u; ?1 y0 n# N4 [, I3 ^! y( H& s9 q1 h
function initializeBall() {
4 a" w. A0 E2 R L x+ u if (document.all) {/ F0 ]- N6 Q- E# a
xMax = document.body.clientWidth
, s. B: P& b" s; F5 L yMax = document.body.clientHeight* o! D! ~2 Y$ G
document.all("supertext").style.visibility = "visible";. Y. F# L( r' @ Z
contentWidth=supertext.offsetWidth3 G% b( k* s a7 t
contentHeight=supertext.offsetHeight
) s8 N% }* E! l2 v5 F$ n/ L }( j) Z6 y( a) C T X: q/ @
else if (document.layers) {* C" z) [) C5 h! Q" E- ^. e5 g9 q
xMax = window.innerWidth;
4 A7 J @0 ^ U% _$ a- U5 B yMax = window.innerHeight;" c3 U0 Z9 n7 s: P- k1 B# J
contentWidth=document.supertext.document.width1 P" B# j' s. w: F- I V/ I3 W
contentHeight=document.supertext.document.height
6 y) {# k' M. C3 G6 m* s2 h1 h" H document.layers["supertext"].visibility = "show";
- Y2 d" L. z$ e7 \3 [ }6 L5 G/ }4 P3 _' ^ d# `- x4 e
setTimeout('moveBall()',400);
0 P& B1 [7 U* ?- H if (hidetimer!='')
: n8 V% B8 [+ ?5 M; T, L( v) J setTimeout("hidetext()",hidetimer)+ x Q, R5 Y% {
}4 ? Z" A( F8 k U0 M0 g) [
( ?" U' b; v! S6 D+ }
function moveBall() {) T5 r* l y' W: `9 F h* p
if (superballRunning == true) {
1 V+ Z9 v8 o! F% D8 m calculatePosition();
+ J( Y) S( L* n7 ]; S if (document.all) {/ P4 I# v0 \# Q- {8 | c2 Z
document.all("supertext").style.left = xPos + document.body.scrollLeft;
( A; E0 H' h7 q/ R% l# `0 K document.all("supertext").style.top = yPos + document.body.scrollTop;0 V. Y9 j6 F8 r1 I E: U) w
}3 M0 t& l1 K; ?) G8 h' b0 ~
else if (document.layers) {
0 x7 \4 d5 h& e8 i+ q* T document.layers["supertext"].left = xPos + pageXOffset;! S, Y/ j+ p. I
document.layers["supertext"].top = yPos + pageYOffset;
: p* Y) z0 @' D. z* F( ^$ Y }
9 x, q/ R4 l3 _7 S2 M animatetext=setTimeout('moveBall()',20);
9 a, W9 Q$ N/ B2 n/ n }9 D5 h% U+ {! h: f+ E
}
( ?; T, b9 J2 L* e( n% \9 R, z9 v
function calculatePosition() {
, b4 D! f7 {/ r7 X% l) V" J if (xDir == "right") {
x! h# q( Q1 Y: v, W9 m: o/ B if (xPos > (xMax - contentWidth - BallSpeed)) {. w8 k7 R( L8 A( C9 n z4 s
xDir = "left";
, l% q5 @' B/ V) _. B }. Z+ }8 Y, I7 {7 C7 n
}
3 E2 h7 D2 V* q7 N else if (xDir == "left") {
# L1 M% w5 l! y' w' u if (xPos < (0 + BallSpeed)) {
; N6 h8 a. U; R" I! d3 y xDir = "right";. ]! o1 l" F6 y% n
}& P& h6 B E! E% s6 u& m3 Q: L* \
}
; }) h9 d1 ~: v1 m6 { H if (yDir == "down") {& \. l" o* x9 s" k' X* ?* G6 J' i
if (yPos > (yMax - contentHeight - BallSpeed)) {
. x# W4 x; K ]! h& _" C: b yDir = "up";: u2 Z0 p) @% G$ x
}2 N9 `9 g, s. j7 C9 a+ K; I' M
}4 t' N# N; [2 x/ T, f; _
else if (yDir == "up") {
" p. X7 b: |6 X3 o0 {. U: W if (yPos < (0 + BallSpeed)) {4 O7 C9 n' Z9 Z$ X6 Q2 s
yDir = "down";
: o9 h2 O" W( C }9 f3 C; U8 x( O# B% c# _
}3 g1 c6 I$ t! V4 O6 s! G
if (xDir == "right") {& D+ u3 D) I0 U: L( g( t, B- G
xPos = xPos + BallSpeed;" j+ x7 k/ k) V7 ?" [9 g1 v) b' ]
}
# x- z2 h% L7 z9 y; l! E3 {# g8 f else if (xDir == "left") {, {' L2 `; U' j$ z6 f e+ }
xPos = xPos - BallSpeed;% {5 b5 s" g3 C# _" M
}: Q3 G) t6 a- t( q5 X8 Q
else {6 Y3 M4 a8 K$ x$ f/ J; \6 D
xPos = xPos;( K( Q( R( F6 m' p2 |+ d* R
}
2 _4 S& @8 L E5 i if (yDir == "down") {
. t- D) M6 m. o' D( L yPos = yPos + BallSpeed;/ a9 }) o2 P" |( o0 ?: {1 d
}8 q, }$ ^6 d( I( f% e5 D1 l5 q0 a5 V
else if (yDir == "up") {. E! y' p% M: e. R. w* A
yPos = yPos - BallSpeed;
2 b3 x% h1 K; M7 o5 F# h& W6 B }. i) e7 H. Y1 u
else {
# F a: |& H# Q. A% y H yPos = yPos;5 K! f5 T0 g* S4 b @6 _: `
}. s9 T$ C5 \- U% p# P- B& t0 q) L
}
/ c- |$ n4 s9 j$ E' _9 a6 T4 n
A, e5 O1 ^% A% p& l1 @function hidetext(){1 R+ i# p* n. i* K
if (document.all)
- `. h6 y6 i% k0 I0 s. m& J4 Vsupertext.style.visibility="hidden"" W! M( q" G0 u! Z" \/ Y0 P: ?
else if (document.layers)
P; y0 b) \( \* h# a; \) V0 Wdocument.supertext.visibility="hide"/ h$ R0 G, Q! ]7 S9 k
clearTimeout(animatetext). a& I; c7 j# w- F+ B( \2 b6 m* ]8 s
}% y* g3 ~! n# F# w
3 h6 k- ?. `# @* Mif (document.all||document.layers){
" Y) F2 Y; J7 O/ {; G, d, bdocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
6 I! o* l5 L6 ~0 ~. {" dwindow.onload = initializeBall;
. f. I$ n( B+ @* Qwindow.onresize = new Function("window.location.reload()");4 J- t8 B- K# o8 F
}
5 J7 m! r: H1 E3 y4 C, `: z3 ^$ H8 h7 z2 q m5 g
</script> |
|