网页之不断弹射的文字-特效
<style type="text/css">#\?^3X7C#supertext {Oqxu r c
position:absolute;
left:0;-j] x,axH5}(sM
top:0;
visibility:hide;
visibility:hidden;
}
</style>
<script language="JavaScript1.2">
<!-- 改变下的字体的大小。颜色-->
var thecontent='<h2><font size="2" face="宋体" color="FF0000">欢迎光临七色风网页家园</font></h2>'g%O ]!b/k%|"k#\
var hidetimer='';ux"M9S(q2{s
<!-- 改变下的弹跳速度-->
var BallSpeed = 20;
var contentWidth;B.X T1~{3A
var contentHeight;f1F8}QW.F
var maxBallSpeed = 50;
#Lf!M sr{.h,F-i
7h0^D"R c.~W@
var xMax;OTJI'w z$]A6s
var yMax;4{*OFzt9`
var xPos = 0;
var yPos = 0;
var xDir = 'right';#T0y,q5Z(B)Ku{m.e_-T
var yDir = 'down';
var superballRunning = true;
var tempBallSpeed;
var currentBallSrc;
var newXDir;e-A1S D FIp4z
var newYDir;
function initializeBall() {
if (document.all) {,m~pvI_-p
xMax = document.body.clientWidtht J5p#SA E/Q5M
yMax = document.body.clientHeight
document.all("supertext").style.visibility = "visible";9s7h'H1E-G.\y}
contentWidth=supertext.offsetWidth7j+^aI4M
contentHeight=supertext.offsetHeight:GR(] H/J n}
}
else if (document.layers) {:[L4xa%Q y1A g
xMax = window.innerWidth;J%{-ML&yp;K
yMax = window.innerHeight;)@_p |e)G q,}
contentWidth=document.supertext.document.width
contentHeight=document.supertext.document.height;|o,BA)PO,K(z.Z
document.layers["supertext"].visibility = "show";.sIm`w7s(f
}
setTimeout('moveBall()',400);/K3y3P_+B/~([
if (hidetimer!='')
setTimeout("hidetext()",hidetimer)
}
U@3V A p)K1jq
function moveBall() {
if (superballRunning == true) {
calculatePosition();D&T)C5E+yq$B
if (document.all) {
document.all("supertext").style.left = xPos + document.body.scrollLeft;
document.all("supertext").style.top = yPos + document.body.scrollTop;` Z9Q8N,sDy
}
else if (document.layers) {8_sG2L~0K:V
document.layers["supertext"].left = xPos + pageXOffset;}8osrG mu~+^
document.layers["supertext"].top = yPos + pageYOffset;.?l}z*N
}
animatetext=setTimeout('moveBall()',20);Y5p|Y7XW9B
}
}wM j M;o3~U)E\a
[JEx2b*N O.qn
function calculatePosition() { f [i}c9C#DA@#dd ^
if (xDir == "right") {
if (xPos > (xMax - contentWidth - BallSpeed)) {
xDir = "left";
}X%?4A8r{8d1K8n8\
}m*H_zry
else if (xDir == "left") {)S C.l1Wm R7rw
if (xPos < (0 + BallSpeed)) {m n^9X/O
xDir = "right";*Pk;\E2L9`Tx
}
}
if (yDir == "down") {
if (yPos > (yMax - contentHeight - BallSpeed)) {MO iC5V:e
yDir = "up";"D c&H-koP(u&Vz p D
}\"oP+lWc!q
}
else if (yDir == "up") {9S v.Qix
if (yPos < (0 + BallSpeed)) {(p~8}Q@3C
yDir = "down";
}sL}L8Og3N
}hJS$N6k
if (xDir == "right") {I,g+I g.a6V
xPos = xPos + BallSpeed;0YV4epu|
}
else if (xDir == "left") {
xPos = xPos - BallSpeed;;yc k9iI}
}9W9n4w(hKj
else {
xPos = xPos;
}
if (yDir == "down") {:O7E ?5b.PrR
yPos = yPos + BallSpeed;\eK"hsiRf
}P/IN R'E4{luA
else if (yDir == "up") {0Ut,}1N`$lKRh,@N
yPos = yPos - BallSpeed;
}
else {#fyzlMXFd p7B$w
yPos = yPos; ce,nW Z'v
}
}W]|lRc2w {A e
function hidetext(){$UF U#yp _'C
if (document.all)Ylc Mky4u|Q
supertext.style.visibility="hidden"/N T!~s8RYmmG)] jp
else if (document.layers),Bq(I^lvN
document.supertext.visibility="hide"H^Z ixQ
clearTimeout(animatetext)
}8T\^4xj6n}Y
.~4Gc3G&^
if (document.all||document.layers){
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
window.onload = initializeBall;B5n9@zRmYkn
window.onresize = new Function("window.location.reload()");bpD3W|
}-WF/uTJexf+k
</script>
页:
[1]