随滚动而滚动,css就可以实现,也就是固定在屏幕固定位置,用 position:fixed;即可,关闭按钮可以用document.getElementById('').style.display='none';即可,如
<div style="width:500px; height:200px; background-color:#F00;position:fixed;left:100px;top:200px;" id="test">
<button onclick="document.getElementById('test').style.display='none';">关闭</button>
</div>
其中left和top都是相对于屏幕的位置
追问不像麻烦了,能够给我完整代码么?谢谢!
追答这已经够完整了亲,我根本不知道你的广告准备放在什么位置,广告宽高多少,里面有什么内容等等。我上面给你的代码,宽是500px,高是200px,背景色是 #F00,位置固定在距屏幕左边100px,距屏幕右边200px,你修改对应数字就可以了