剑晨玷污楚楚漫画:用Frontpage制作网页,如何才能让图片流动!
来源:百度文库 编辑:高校问答 时间:2024/04/29 03:33:31
http://www.edu517.com/Index.html 大家看,这网页中间的图片不就在不停的流动吗?请问怎么做?谢谢大家了!
图片在页面内随意飘动,遇到边界还会反弹。
代码比较长
<div id="img" style="position:absolute;">
<a href="http://www.helpor.net" target="_blank">
<img src="http://code.helpor.net/picture/swimming.gif" border="0"></a>
</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
var xPos = 20;
var yPos = document.body.clientHeight;
var step = 1;
var delay = 30;
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
img.style.top = yPos;
function changePos() {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = img.offsetHeight;
Woffset = img.offsetWidth;
img.style.left = xPos + document.body.scrollLeft;
img.style.top = yPos + document.body.scrollTop;
if (yon) {
yPos = yPos + step;
}
else {
yPos = yPos - step;
}
if (yPos < 0) {
yon = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
yon = 0;
yPos = (height - Hoffset);
}
if (xon) {
xPos = xPos + step;
}
else {
xPos = xPos - step;
}
if (xPos < 0) {
xon = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
xon = 0;
xPos = (width - Woffset);
}
}
function www_helpor_net() {
img.visibility = "visible";
interval = setInterval('changePos()', delay);
}
www_helpor_net();
//For more,visit:www.helpor.net
-->
</script>