我要在页面两侧加上两个图片随网页上下浮动,要怎么实现?急 啊 !!
求助各位高人!!!!!

解决方案 »

  1.   

    <script>
    var obj1=null;
    var obj2=null;
    var ts;
    window.onload=Init;
    function Init()
    {
      obj1=document.getElementById("div1");
      obj2=document.getElementById("div2");
      obj1.style.left=parseInt(document.body.clientWidth)-parseInt(obj1.offsetWidth)+"px";//居右
      obj1.style.top=0;
      obj2.style.left=0;
      obj2.style.top=0;
      ts=setInterval(CheckPos,10); //控制位置函数
    }
    function CheckPos()
    {
      obj1.style.top=document.body.scrollTop+"px";
      obj2.style.top=document.body.scrollTop+"px";
    }
    </script>
    <body>
    <div id="div1" style="position:absolute;">       
    <img src="caribi.gif"/> </div>
    <div id="div2" style="position:absolute;">       
    <img src="caribi.gif"/> </div>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
      

  2.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>侧边广告</title>
    <script language="javascript">
    //设定相对位置
    imgleft=170;
    imgHeight=250;
    //图片移动函数
    function imgmove(){
    mylayer.style.top=document.body.scrollTop+document.body.offsetHeight-imgHeight;
    mylayer.style.left=document.body.offsetWidth-imgleft;
    mylayer1.style.top=document.body.scrollTop+document.body.offsetHeight-imgHeight;
    mylayer1.style.right=document.body.offsetWidth-imgleft;
    setTimeout("imgmove()",80);
    }
    </script>
    </head>
    <body onLoad="imgmove()">
    <h1> </h1>
    <h1> </h1>
    <h1> </h1>
    <h1> </h1>
    <h1> </h1>
    <h1> </h1>
    <h1> </h1>
    <h1> </h1>
    <h1> </h1>
    <h1> </h1>
    <h1> </h1>
    <h1> </h1><center>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>www
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>www
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>www<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>www</center>
    <div id="mylayer" style="position:absolute;width:64;top:300;hidden:visible;z-index:1; margin-left:20px;"><img src="http://www.phpfans.net/bbs/customavatars/2.jpg" width="100" height="120"></div>
    <div id="mylayer1" style="position:absolute;width:64;top:300;hidden:visible;z-index:1; margin-right:20px"><img src="http://www.phpfans.net/bbs/customavatars/2.jpg" width="100" height="120"></div>
    </body>
    </html> 
      

  3.   

    多参考Dom手册
    www.w3school.com.cn