捌玖网络工作室's Archiver

zw2004 发表于 2008-1-21 20:55

网页之不断弹射的文字-特效

<style type="text/css">
bKx N0O&\@ #supertext {
[1SU4u"dRk!o;p position:absolute;
W*O hH,b'O left:0;
(W1G*S,lsuE3}UM top:0;
*z\ ?7n/R[q visibility:hide;
)v8]"pd4R,t visibility:hidden;+G*yjmq9P _%J*l
}X2cI4k:O(s
</style>
]*J4u~]X\l <script language="JavaScript1.2">;h&U] u(N.a!H
<!-- 改变下的字体的大小。颜色-->'l&T*I'~?
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'
j.^w/]m:g{Y var hidetimer='';1d.[ o }VO,M z
<!-- 改变下的弹跳速度-->
0oP3C5f{lA4b&xV var BallSpeed = 20;
1nIU]l7up var contentWidth;%Y3YD akKW%w
var contentHeight;
Ktp f4i)\g Cn3i var maxBallSpeed = 50;&LO \~#`kMP p

T Hb@J
`*gD8FJ var xMax;
.m-Y8K7Pv6U:X? var yMax;
rs(P@V0}0i var xPos = 0;
7\6O,[&Nd? var yPos = 0;3L2oE,[7DU+pw n
var xDir = 'right';
!w_~!f,L'j W var yDir = 'down';
n"J$\b$r$\ var superballRunning = true;It2T6a#oo#h
var tempBallSpeed;
+c;i)IK Jvc var currentBallSrc;
'ni4p2s3L6Ny var newXDir;-~ Rd"^ J0UPF$j
var newYDir;%n f w6Bx Vu0o:|

}.^-O R9qW function initializeBall() {
\8W y CM\*B2C PA$o    if (document.all) {
dp7P$c,}[:Ey7|       xMax = document.body.clientWidth
YC{4C0S6V T^       yMax = document.body.clientHeight
&rue5DGnm,G       document.all("supertext").style.visibility = "visible";gq[jB
      contentWidth=supertext.offsetWidth
m#B|"y(oE       contentHeight=supertext.offsetHeight
2r)xh6B&sy`       }
|L(j;l@    else if (document.layers) {~0L2pS[Y*U
      xMax = window.innerWidth;MOC$OJp7cUY$O
      yMax = window.innerHeight;(G,o/j7N#dvV(E
      contentWidth=document.supertext.document.width
'j(~6AXR Q       contentHeight=document.supertext.document.height
d7~!@K pF       document.layers["supertext"].visibility = "show";
6\fW0D/UUf       }
M8ih#? T    setTimeout('moveBall()',400);
8WKj4G4W(xob#c    if (hidetimer!='')
gYF;H8a/Y}+EG    setTimeout("hidetext()",hidetimer)
#Rp8B8aC    }
|@L\qn]o(| G9U(vR7C_)U/w A
function moveBall() {D-^ xh|#|S6^
   if (superballRunning == true) {
d.Q)tu+X2f%@       calculatePosition();
n!\-n-x%uIJ       if (document.all) {
(Ix)zi/^{c          document.all("supertext").style.left = xPos + document.body.scrollLeft;A+a e"_p0DN.k\
         document.all("supertext").style.top = yPos + document.body.scrollTop;
7irg&b6X#y:_`3r"Z&M          }
zw \)X*K j+F       else if (document.layers) {
UW d9xh:bR5\          document.layers["supertext"].left = xPos + pageXOffset;
FI5z Xm0t;n'?%q          document.layers["supertext"].top = yPos + pageYOffset;Em'^m Pnl
         } |)e'd'Uqcf o3y
      animatetext=setTimeout('moveBall()',20);
3G S(PbhD       }*|D-[d f z
   }
WW-C-C4@ Ub}Uz \H,y;p$Lk5x
function calculatePosition() {
U wTZ7s p    if (xDir == "right") {n|.K5@ N P6q8w
      if (xPos > (xMax - contentWidth - BallSpeed)) {.M Ce.k%~ o A
         xDir = "left";
Y%[k/ff ?,`F-@          }6? @(P$Z3B9}uO+v
      }.z#i*l i-Q+I
   else if (xDir == "left") {kb;N.C _6sBe]g5O
      if (xPos < (0 + BallSpeed)) {
{g2~5u"p          xDir = "right";5rh;r\6? \
         }
*j*l}z6`       }
y8J^]wr4N IR    if (yDir == "down") {
c?A2ZF:Li:\       if (yPos > (yMax - contentHeight - BallSpeed)) {
O D[4r3Vm%C^(yw1M          yDir = "up";} ek&a1D
         } y:NZ4{?:u
      },G B&P9Jtj,S*i
   else if (yDir == "up") {
4swk]$K(]&R5P#S)@       if (yPos < (0 + BallSpeed)) {8Ez0v!B]A }+C
         yDir = "down";
R]Q_SN          }^ G:f3~9{
      }
|Ya2p)P2x:VAE    if (xDir == "right") {
[6D.nh ST:jt       xPos = xPos + BallSpeed;&P$kuh n}P0{6F
      }|,j k#q-@2I(m3vVu
   else if (xDir == "left") {\6|7`,p SR;_y#B
      xPos = xPos - BallSpeed;
1BO8T#Mqd`       } hqZ-T_4FX g;~A
   else {
6yPP8oL*v3e ?'_       xPos = xPos;
0B7t3A(k/k3k       }
)g K+e0I R0\    if (yDir == "down") { H*dh,V/dT
      yPos = yPos + BallSpeed;fz{ x2~L
      })iS2k&VhN4?mOs
   else if (yDir == "up") {yuqkJ z9PbX
      yPos = yPos - BallSpeed;
#a!vAv9XI       }
7X l'~-X K8N-aV WD    else {w2B:cy:Vd3k
      yPos = yPos;$m\'Q$g@` hF/w
      })FL}fCd%V#P#z3]
   }k!}?RC

9r0MI4Fl-SN function hidetext(){6u3E~ K7U,{5Nq1c5w
if (document.all)]9F lH e
supertext.style.visibility="hidden"
v&{,y2~ [:]!} else if (document.layers)W1Z CUl;K(?*W{G
document.supertext.visibility="hide"
Pg Y)sIP8r w clearTimeout(animatetext)
u+Qs6i _ }aqpXq h\[

/YkN m'zQG if (document.all||document.layers){
Qg1Pl9O#x_m5j3z document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')_l\Z_)`"Dt:M
window.onload = initializeBall;~r0s:a*K@
window.onresize = new Function("window.location.reload()");
4])Up2h/[dz }
gbM+TFO E
Y w:|"vScp C </script>

页: [1]
【捌玖网络】已经运行:


Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.