<SCRIPT FOR=window EVENT=onload LANGUAGE=”JScript”>
initAd();//载入页面后,调用函数initAd()
</SCRIPT>
<script language=”JScript”>
<!–
function initAd() {
document.all.AdLayer.style.posTop = -200;//设置onLoad事件激发以后,广告层相对于固定后的y方向位置
document.all.AdLayer.style.visibility = ‘visible’//设置层为可见
MoveLayer(‘AdLayer’);//调用函数MoveLayer()
}
function MoveLayer(layerName) {
var x = 60;//浮动广告层固定于浏览器的x方向位置
var y = 100;//浮动广告层固定于浏览器的y方向位置
var diff = (document.body.scrollTop + y – document.all.AdLayer.style.posTop)*.40;
var y = document.body.scrollTop + y – diff;
eval(“document.all.” + layerName + “.style.posTop = y”);
eval(“document.all.” + layerName + “.style.posLeft = x”);//移动广告层
setTimeout(“MoveLayer(‘AdLayer’);”, 20);//设置20毫秒后再调用函数MoveLayer()
}
//–>
</script>
调用如下
\n
<div id=AdLayer style=’position:absolute; width:61px; height:59px; z-index:20; visibility:hidden;; left: 60px; top: 100px’>
<img src=’map.jpg’ border=”0″ height=”200″>
</div>
\n
来源:网络
\n