<script language="JavaScript" type="text/javascript" >lastScrollY=0;
function heartBeat(){
var diffY;
if (document.documentElement && document.documentElement.scrollTop)
diffY = document.documentElement.scrollTop;
else if (document.body)
diffY = document.body.scrollTop
else
{/*Netscape stuff*/}//alert(diffY);
percent=.1*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("ALayer1").style.top=parseInt(document.getElementById("ALayer1").style.top)+percent+"px";
document.getElementById("ALayer2").style.top=parseInt(document.getElementById("ALayer1").style.top)+percent+"px";lastScrollY=lastScrollY+percent;
//alert(lastScrollY);
}
suspendcode12="<DIV id=\"ALayer1\" style='left:0px;PosITION:absolute;TOP:100px;'><br><br><img src='http://www.jiaodong.net/images/a_close.gif' border=0 onclick='closeBanner();' /><br><br><EMBED src='http://www.jiaodong.net/a/index/desheng.swf' quality=high  WIDTH=95 HEIGHT=160 TYPE='application/x-shockwave-flash' id=EccoolAd wmode=transparent></EMBED><br><br><a href='http://www.jiaodong.net/travel/51/' target='_blank'><img src='http://www.jiaodong.net/a/index/wuyi.jpg' width='95' height='90' border='0' /></a><br><br><EMBED src='http://www.jiaodong.net/a/index/xinan.swf' quality=high  WIDTH=95 HEIGHT=90 TYPE='application/x-shockwave-flash' id=EccoolAd wmode=transparent></EMBED></div>"
suspendcode14="<DIV id=\"ALayer2\" style='right:0px;PosITION:absolute;TOP:100px;'><br><br><img src='http://www.jiaodong.net/images/a_close.gif' border=0 onclick='closeBanner();' /><br><br><EMBED src='http://www.jiaodong.net/a/index/taiwushi.swf' quality=high  WIDTH=95 HEIGHT=160 TYPE='application/x-shockwave-flash' id=EccoolAd wmode=transparent></EMBED><br><br><a href='http://www.jiaodong.net/a/070313pijiu/' target=_blank><img src=http://www.jiaodong.net/a/index/ytbeer.gif border=0></a><br><br><EMBED src='http://www.jiaodong.net/a/index/renai.swf' quality=high  WIDTH=95 HEIGHT=90 TYPE='application/x-shockwave-flash' id=EccoolAd wmode=transparent></EMBED></div>"
document.write(suspendcode12);
document.write(suspendcode14);
window.setInterval("heartBeat()",1);
function closeBanner()
{
document.getElementById("ALayer1").style.display= 'none';
document.getElementById("ALayer2").style.display= 'none';
}
</script>我最近弄的一个,可以正常滚动。拿去试试吧。

解决方案 »

  1.   

    参考:
    http://www.xgtx.gov.cn/index.asp
      

  2.   

    IE6 FF OP的说。。只是把 document.body改成了document.documentElement
    米IE7所以测不了那个。。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <style type="text/css">
    html, body {
    margin:0px;
    padding:0px;
    }
    #lwc, #rwc {
    width:100px;
    height:500px;
    background:#009999;
    border:#336699 1px dashed;
    }
    #lwc, #rwc, #lwc_c, #rwc_c {
    display:none;
    }
    </style>
    <script type="text/javascript">
    function $(id) {
    return document.getElementById(id);
    }function scrollBanner(timer, moveNumber) {

    function move(o) {
    var st = document.documentElement.scrollTop + o.t;
    var sl = document.documentElement.scrollLeft + (o.c == 0 ? o.a : document.documentElement.clientWidth - o.a - o.offsetWidth);
    var tc = st - o.offsetTop, lc = sl - o.offsetLeft;
    with (o.style) {
    top = o.offsetTop + (tc != 0 ? tc / Math.abs(tc) : 0) * Math.min(Math.abs(tc), moveNumber) + "px";
    left = o.offsetLeft + (lc != 0 ? lc / Math.abs(lc) : 0) * Math.min(Math.abs(lc), moveNumber) + "px";
    }
    if (o.person) {
    with (o.person.style) {
    top = o.offsetTop + "px";
    left = o.offsetLeft + o.offsetWidth - o.person.offsetWidth + "px";
    }
    }
    }

    var hidden = function() {
    var o = this.parent;
    window.clearInterval(o.interval);
    o.parentNode.removeChild(o);
    this.parentNode.removeChild(this);
    }

    this.add = function (to, t, a, c, lo) {
    /*
    to为object对象
    t为距离顶端距离
    当c = 0的时候,a为距离左边的距离
    当c != 0的时候,a为距离右边的距离
    lo为关闭按钮
    */
    var div, exec = function () {
    move(to);
    };

    to.person = lo;
    to.t = t;
    to.a = a;
    to.c = c;
    with (to.style) {
    position = "absolute";
    display = "block";
    top = document.documentElement.scrollTop + t;
    left = document.documentElement.scrollLeft + (c == 0 ? a : document.documentElement.clientWidth - a - to.offsetWidth);
    }

    if ("undefined" != typeof lo) {
    with (lo.style) {
    position = "absolute";
    display = "block";
    }
    lo.onmousedown = hidden;
    lo.parent = to;
    }
    exec();
    to.interval = window.setInterval(exec, timer);
    };
    }window.onload = function () {
    var b = new scrollBanner(10, 3);
    b.add($("lwc"), 50, 10, 0, $("lwc_c"));
    b.add($("rwc"), 50, 10, 1, $("rwc_c"));
    b = null;
    }
    </script>
    </head>
    <body>
    <div id="lwc"></div>
    <div id="rwc"></div>
    <input id="lwc_c" type="button" value="关&nbsp;&nbsp;闭" />
    <input id="rwc_c" type="button" value="关&nbsp;&nbsp;闭" />
    <div style="height:1000px;"></div>
    </body>
    </html>