function scrolls(){
var advobj=document.getElementById("adv")
advobj.style.top=100+document.documentElement.scrollTop+"px"
}
window.onscroll=scrolls
function winclose(){
var advobj=document.getElementById("adv")
advobj.style.display="none"
}
</script>
<body>
<!--随滚动条移动的浮动窗口############################-->
<div id="adv" style="">
<img src="图片路径"/>
<div id="close" onclick="winclose()">关闭</div>
</div>
<div id="header"><iframe src="header.html" height="155px" width="960px" frameborder="0"scrolling="no"></iframe></div>
</body>
请将代码放置在<head></head>之间即可<script language="javascript">
suspendcode="<DIV id=lovexin style='Z-INDEX: 10LEFT: 850pxPOSITION: absoluteTOP: 140pxwidth: 88pxheight: 203px'><a href='http://www.ixym.net'><img src='../20080128/er_p.jpg' width='150' height='200' border='0'></a></DIV>"
document.write(suspendcode)
lastScrollY=0
function heartBeat(){
diffY=document.body.scrollTop
percent=.1*(diffY-lastScrollY)
if(percent>0)percent=Math.ceil(percent)
else percent=Math.floor(percent)
document.all.lovexin.style.pixelTop+=percent
lastScrollY=lastScrollY+percent
}
window.setInterval("heartBeat()",1)
</script>
代码说明:
1、加到左侧的时候,把left属性改为10就好;
2、TOP是控制这个浮动广告离上边的距离,可以根据自己的实际情况进行调整;
3、这里href='http://www.ixym.net和这里img src='../20080128/er_p.jpg' 换成你想要的浮动广告的图片。其中这句src=../20080128/er_p.jpg' width='150' height='200'border='0' 中WIDTH=‘150’ height='200'是你浮动广告图片的宽和高。