<head>與</head>之間
<script language="javascript">
<!--
lastScrollY=0;
function rollimg(){
var varY = document.body.scrollTop;
if (varY <= 0)
{
varY = document.documentElement.scrollTop;
}
percent=.1*(varY-lastScrollY);
if(percent >0 )
percent=Math.ceil(percent);
else
percent=Math.floor(percent);
var top = parseInt(document.getElementById("floatlayer").style.top);
document.getElementById("floatlayer").style.top = (top += percent) + "px";
lastScrollY += percent;
document.getElementById("floatlayer").style.left=(document.body.clientWidth/2+357)+"px";
}
window.setInterval("rollimg()",1);
//-->
</script>
<!--
lastScrollY=0;
function rollimg(){
var varY = document.body.scrollTop;
if (varY <= 0)
{
varY = document.documentElement.scrollTop;
}
percent=.1*(varY-lastScrollY);
if(percent >0 )
percent=Math.ceil(percent);
else
percent=Math.floor(percent);
var top = parseInt(document.getElementById("floatlayer").style.top);
document.getElementById("floatlayer").style.top = (top += percent) + "px";
lastScrollY += percent;
document.getElementById("floatlayer").style.left=(document.body.clientWidth/2+357)+"px";
}
window.setInterval("rollimg()",1);
//-->
</script>
<body>與</body>之間
<DIV id="floatlayer" style="position: absolute; top: 50px">
亦可寫成document.getElementById("floatlayer").style.left=50+"px"直接帶入數值。
※註2:若要修改幅動圖層距離頁首的距離請修改top: 50px; 數值。
沒有留言:
張貼留言