分享

在网页中移动的文字和图片代码

 mufu136 2011-12-13
在网页中移动的文字和图片代码

发表日期:2011年10月7日  本页面已被访问 414 次

在网页中移动的文字和图片代码

<STYLE type=text/css>
#supertext {
position:absolute;
left:0;
top:0;
visibility:hide;
visibility:hidden;
}
</STYLE>

<SCRIPT language=JavaScript1.2>
<!-- 改变下的字体的大小。颜色-->
var thecontent='<h2><FONT size=6><FONT color=#e00000>人</FONT><FONT color=#c71900>到</FONT><FONT color=#ae3200>中</FONT><FONT color=#954b00>年</FONT><FONT color=#7c6400>欢</FONT><FONT color=#637d00>迎</FONT><FONT color=#4a9600>您</FONT><FONT color=#31af00>的</FONT><FONT color=#18c800>到</FONT><FONT color=#00e000>来</FONT></FONT><br><p align=center><IMG height=110 src="http://cache37.51.com/photo3/c3/0c/qtaywwg/4650083a7346141e0fb413bd53f7f4a6.gif" width=100></P> </h2>'
var hidetimer='';
<!-- 改变下的弹跳速度-->
var BallSpeed = 2;
var contentWidth;
var contentHeight;
var maxBallSpeed = 3;

var xMax;
var yMax;
var xPos = 0;
var yPos = 0;
var xDir = 'right';
var yDir = 'down';
var superballRunning = true;
var tempBallSpeed;
var currentBallSrc;
var newXDir;
var newYDir;
function initializeBall() {
   if (document.all) {
      xMax = document.body.clientWidth
      yMax = document.body.clientHeight
      document.all("supertext").style.visibility = "visible";
      contentWidth=supertext.offsetWidth
      contentHeight=supertext.offsetHeight
      }
   else if (document.layers) {
      xMax = window.innerWidth;
      yMax = window.innerHeight;
      contentWidth=document.supertext.document.width
      contentHeight=document.supertext.document.height
      document.layers["supertext"].visibility = "show";
      }
   setTimeout('moveBall()',400);
   if (hidetimer!='')
   setTimeout("hidetext()",hidetimer)
   }
function moveBall() {
   if (superballRunning == true) {
      calculatePosition();
      if (document.all) {
         document.all("supertext").style.left = xPos + document.body.scrollLeft;
         document.all("supertext").style.top = yPos + document.body.scrollTop;
         }
      else if (document.layers) {
         document.layers["supertext"].left = xPos + pageXOffset;
         document.layers["supertext"].top = yPos + pageYOffset;
         }
      animatetext=setTimeout('moveBall()',20);
      }
   }
function calculatePosition() {
   if (xDir == "right") {
      if (xPos > (xMax - contentWidth - BallSpeed)) {
         xDir = "left";
         }
      }
   else if (xDir == "left") {
      if (xPos < (0 + BallSpeed)) {
         xDir = "right";
         }
      }
   if (yDir == "down") {
      if (yPos > (yMax - contentHeight - BallSpeed)) {
         yDir = "up";
         }
      }
   else if (yDir == "up") {
      if (yPos < (0 + BallSpeed)) {
         yDir = "down";
         }
      }
   if (xDir == "right") {
      xPos = xPos + BallSpeed;
      }
   else if (xDir == "left") {
      xPos = xPos - BallSpeed;
      }
   else {
      xPos = xPos;
      }
   if (yDir == "down") {
      yPos = yPos + BallSpeed;
      }
   else if (yDir == "up") {
      yPos = yPos - BallSpeed;
      }
   else {
      yPos = yPos;
      }
   }
function hidetext(){
if (document.all)
supertext.style.visibility="hidden"
else if (document.layers)
document.supertext.visibility="hide"
clearTimeout(animatetext)
}
if (document.all||document.layers){
document.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
window.onload = initializeBall;
window.onresize = new Function("window.location.reload()");
}
</SCRIPT>
</SPAN></SPAN></SPAN></TR></TBODY>
<DIV></DIV>



    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多