制作页面漂浮图片的效果(2) } else if (document.getElementById) { document.getElementById("superball").style.left = xPos + pageXOffset; document.getElementById("superball").style.top = yPos + pageYOffset; } setTimeout('moveBall()',30); } } function calculatePosition() { if (xDir == "right") { if (xPos > (xMax - ballWidth - BallSpeed)) { xDir = "left"; } } else if (xDir == "left") { if (xPos < (0 + BallSpeed)) { xDir = "right"; } } if (yDir == "down") { if (yPos > (yMax - ballHeight - 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; } } if (document.alldocument.layersdocument.getElementById){ window.onload = initializeBall; window.onresize = new Function("window.location.reload()"); } // end hiding from old browsers --> </script> 请继续在<body></body>之间粘贴层,代码: <span id="superball"><a href="http://www.netbei.com/" target=_blank><img name="superballImage" src="../images/mainlogo.gif" border="0"></a></span> 附加说明: 1.请自行制作一个适合你自己的图片,如本处所使用的"mainlogo.gif",如果你的图片尺寸有所改变请查找第一步和第二步中代码的width和height的值进行修改 2.将第三步中的<a href="http://www.netbei.com">换成你的链接即可!