RT,页面比较大,有横向纵向的滚动条,要一幅广告图片,不管滚动条横向还是纵向移动,图片始终保持在浏览器的左上角。请高手给代码,谢谢。

解决方案 »

  1.   

    把所有的广告放到一个div里,用滚动条来控制div的位置就可以了
      

  2.   

    符合标准的正常工作的对联广告
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>符合标准的正常工作的对联广告</title>
    <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("lovexin12").style.top=parseInt(document.getElementById("lovexin12").style.top)+percent+"px";
    document.getElementById("lovexin14").style.top=parseInt(document.getElementById("lovexin12").style.top)+percent+"px";
    lastScrollY=lastScrollY+percent;
    //alert(lastScrollY);
    }
    suspendcode12="<div id=\"lovexin12\" style='left:2px;position:absolute;top:120px;'>ad1</div>"
    suspendcode14="<div id=\"lovexin14\" style='right:2px;position:absolute;top:120px;'>ad2</div>"
    document.write(suspendcode12);
    document.write(suspendcode14);
    window.setInterval("heartBeat()",1);
    </script>
    <style type="text/css">
    <!--
    html,body{height:1000px;}
    #lovexin12,#lovexin14{width:120px; height:250px; background-color:#e5e5e5; border:1px solid #ddd;}
    #mm{height:1000px;}
    -->
    </style>
    </head>
    <body>
    <div id="mm">
    </div>
    </body>
    </html>
      

  3.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var curLeft = 0;
    var curTop = 0;
    window.onload = function() {
    curLeft = document.getElementById("adv").style.pixelLeft;
    curTop = document.getElementById("adv").style.pixelTop;
    } function show() {
    document.getElementById("adv").style.pixelLeft = document.body.scrollLeft + document.getElementById("adv").scrollLeft;
    document.getElementById("adv").style.pixelTop = document.body.scrollTop + document.getElementById("adv").scrollTop;
    } window.onscroll = show;
    //-->
    </SCRIPT>
    </HEAD><BODY>
    <div style="position:absolute;z-index:1;" id="adv">
    <img src="">
    </div>
    </BODY>
    </HTML>