<div id="FloatDIV" align="center">
            <TABLE cellSpacing=0 cellPadding=0 width=212 border=0>
              <TBODY>
              <TR>
                <TD align=middle height=32>
<img src="images/2/index_066.gif" width="215" height="32" alt=""></TD>
  </TR>
  <tr>
  <td align=middle height=55 bgcolor="#ffffff">
  <iframe src="http://weather.liehuo.net/weather/54827.htm" width="160" height="55" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
 </td>
  </tr>
  </TBODY>
</TABLE>
</div>
 <script language="javascript" type="text/javascript">
var MarginLeft = 780;   //浮动层离浏览器右侧的距离
var MarginTop = 50;     //浮动层离浏览器顶部的距离
var Width =216;        //浮动层宽度
var Heigth= 87;        //浮动层高度//设置浮动层宽、高
function Set()
{
    document.getElementById("FloatDIV").style.width = Width;
    document.getElementById("FloatDIV").style.height = Heigth;
}//实时设置浮动层的位置
function Move()
{
    document.getElementById("FloatDIV").style.top = document.documentElement.scrollTop + MarginTop;
    document.getElementById("FloatDIV").style.left = document.documentElement.clientWidth - Width - MarginLeft;
    setTimeout("Move();",100);
}Set();
Move();
</script>
问题:这是定义了一个层,然后其中有一个表格和iframe框,框中引入一个天气预报连接。下面是一段JAVA代码用来实现操纵层,实现随滚动条滚动的效果,但为什么并不滚动呢,错在哪,谢谢

解决方案 »

  1.   

    //设置浮动层宽、高 
    function Set() 

        document.getElementById("FloatDIV").style.width = Width; 
        document.getElementById("FloatDIV").style.height = Heigth; 

    函数有问题不工作,导致后面无法执行
      

  2.   

    1.加TDT头
    2.加CSS:position :absolute<!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" xml:lang="zh-CN" lang="zh-CN"><div id="FloatDIV" align="center" style="position :absolute"> 
    <TABLE cellSpacing=0 cellPadding=0 width=212 border=0> 
      <TBODY> 
      <TR> 
        <TD align=middle height=32> 
    <img src="images/2/index_066.gif" width="215" height="32" alt=""> </TD> 
      </TR> 
      <tr> 
      <td align=middle height=55 bgcolor="#ffffff"> 
      <iframe src="http://weather.liehuo.net/weather/54827.htm" width="160" height="55" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"> </iframe></td> 
      </tr> 
      </TBODY> 
    </TABLE> 
    </div> 
    <script language="javascript" type="text/javascript"> 
    var MarginLeft = 780;  //浮动层离浏览器右侧的距离 
    var MarginTop = 50;    //浮动层离浏览器顶部的距离 
    var Width =216;        //浮动层宽度 
    var Heigth= 87;        //浮动层高度 //设置浮动层宽、高 
    function Set(){ 
        document.getElementById("FloatDIV").style.width = Width; 
        document.getElementById("FloatDIV").style.height = Heigth; 
    } //实时设置浮动层的位置 
    function Move(){ 
        document.getElementById("FloatDIV").style.top = document.documentElement.scrollTop + MarginTop; 
        document.getElementById("FloatDIV").style.left = document.documentElement.clientWidth - Width - MarginLeft; 
        setTimeout("Move();",100); 
    } Set(); 
    Move(); 
    </script> 
    <div style="height:999px;"></div>
      

  3.   

    function Move() 

        document.getElementById("FloatDIV").style.top = document.documentElement.scrollTop + MarginTop; 
        document.getElementById("FloatDIV").style.left = document.documentElement.clientWidth - Width + MarginLeft; 
        setTimeout("Move();",100); 
    } FF和IE有点差别...IE先这样...
      

  4.   

    //实时设置浮动层的位置 
    function Move() 
    {
        if(document.body){ 
          document.getElementById("FloatDIV").style.top = document.body.scrollTop + MarginTop;
          document.getElementById("FloatDIV").style.left = document.body.clientWidth - Width - MarginLeft;
        }else{
          document.getElementById("FloatDIV").style.top = document.documentElement.scrollTop + MarginTop; 
          document.getElementById("FloatDIV").style.left = document.documentElement.clientWidth - Width - MarginLeft;
        }
        setTimeout("Move();",1000); 
    } 改成这样IE和FF都可以了...
    sorry.由于是网上拿的代码.没认真检查.
      

  5.   

    发现一个小问题同是MS IE6在 WIN2000和 WIN XP下 不同:
    WIN2000:document.documentElement.clientWidth 属性有效
    WIN XP: document.documentElement.clientWidth 属性无效,得0,估计这导致代码不执行了,
      

  6.   


    <!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" xml:lang="zh-CN" lang="zh-CN"><div id="FloatDIV" align="center" style="position :absolute"> 
    <TABLE cellSpacing=0 cellPadding=0 width=212 border=0> 
      <TBODY> 
      <TR> 
        <TD align=middle height=32> 
            <img src="images/2/index_066.gif" width="215" height="32" alt=""> </TD> 
      </TR> 
      <tr> 
      <td align=middle height=55 bgcolor="#ffffff"> 
          <iframe src="http://weather.liehuo.net/weather/54827.htm" width="160" height="55" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"> </iframe></td> 
      </tr> 
      </TBODY> 
    </TABLE> 
    </div> 
    <script language="javascript" type="text/javascript"> 
    var MarginLeft = 780;  //浮动层离浏览器右侧的距离 
    var MarginTop = 50;    //浮动层离浏览器顶部的距离 
    var Width =216;        //浮动层宽度 
    var Heigth= 87;        //浮动层高度 //设置浮动层宽、高 
    function Set(){ 
        document.getElementById("FloatDIV").style.width = Width; 
        document.getElementById("FloatDIV").style.height = Heigth; 
    } //实时设置浮动层的位置 
    function Move(){ 
        document.getElementById("FloatDIV").style.top = document.documentElement.scrollTop + MarginTop; 
        document.getElementById("FloatDIV").style.left = document.documentElement.clientWidth - Width - MarginLeft; 
        setTimeout("Move();",100); 
    } Set(); 
    Move(); 
    </script> 
    <div style="height:999px;"></div>
      

  7.   

    还是不动啊,到底是什么原因啊,是参数设错了。还是java脚本,放错位置了
      

  8.   

    不行啊,加上position这个层就会消失
      

  9.   

    不行啊,不管我怎么该,它都无动于衷
    现在的代码让我改为了:<div id="FloatDIV" align="center" style="">
                <TABLE width=212 border=0 cellPadding=0 cellSpacing=0 bgcolor="#FFFFFF"  >
                 
                  <TR>
                    <TD><img src="images/2/index_066.gif" width="215" height="32" alt="" /></TD>
      </TR>
      <tr>
      <td>
      <iframe src="http://weather.liehuo.net/weather/54827.htm" width="160" height="55" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>  </td>
      </tr>
    </TABLE>
    </div>
    <script language="javascript" type="text/javascript"> 
    var MarginLeft = 200;  //浮动层离浏览器右侧的距离 
    var MarginTop = 50;    //浮动层离浏览器顶部的距离 
    var Width =200;        //浮动层宽度 
    var Heigth= 80;        //浮动层高度 //设置浮动层宽、高 
    function Set() 

        document.getElementById("FloatDIV").style.width = Width; 
        document.getElementById("FloatDIV").style.height = Heigth; 
    } //实时设置浮动层的位置 
    function Move() 
    {
        if(document.body){ 
          document.getElementById("FloatDIV").style.top = document.body.scrollTop + MarginTop;
          document.getElementById("FloatDIV").style.left = document.body.clientWidth - Width - MarginLeft;
        }else{
          document.getElementById("FloatDIV").style.top = document.documentElement.scrollTop + MarginTop; 
          document.getElementById("FloatDIV").style.left = document.documentElement.clientWidth - Width - MarginLeft;
        }
        setTimeout("Move();",100); 
    }
    Set(); 
    Move(); 
    </script> 究竟是怎么回事啊。
      

  10.   

    <div id="FloatDIV" align="center" style="position :absolute"> 
    试试
      

  11.   

    <!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" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <meta name="keywords" content="">
    <meta name="description" content="">
    <title></title><link rel="stylesheet" rev="stylesheet" href="http://www.9191w.net/skin/xunlei2008/css/game_base.css" type="text/css" media="all" />
    <link rel="stylesheet" rev="stylesheet" href="http://www.9191w.net/skin/xunlei2008/css/game_index.css" type="text/css" media="all" />
    <link rel="stylesheet" rev="stylesheet" href="http://www.9191w.net/skin/xunlei2008/css/style.css" type="text/css" media="all" /></head>
    <body>
    <div id="FloatDIV" align="center" style="position:absolute"> 
                <TABLE width=212 border=0 cellPadding=0 cellSpacing=0 bgcolor="#FFFFFF"  > 
                
                  <TR> 
                    <TD> <img src="images/2/index_066.gif" width="215" height="32" alt="" /> </TD> 
      </TR> 
      <tr> 
      <td> 
      <iframe src="http://weather.liehuo.net/weather/54827.htm" width="160" height="55" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"> </iframe> </td> 
      </tr> 
    </TABLE> 
    </div> 
    <script language="javascript" type="text/javascript"> 
    var MarginLeft = 200;  //浮动层离浏览器右侧的距离 
    var MarginTop = 50;    //浮动层离浏览器顶部的距离 
    var Width =200;        //浮动层宽度 
    var Heigth= 80;        //浮动层高度 //设置浮动层宽、高 
    function Set() 

        document.getElementById("FloatDIV").style.width = Width; 
        document.getElementById("FloatDIV").style.height = Heigth; 
    } //实时设置浮动层的位置 
    function Move() 

        if(document.body){ 
          document.getElementById("FloatDIV").style.top = document.body.scrollTop + document.documentElement.scrollTop + MarginTop; 
          document.getElementById("FloatDIV").style.left = document.body.clientWidth - Width - MarginLeft; 
        }else{ 
          document.getElementById("FloatDIV").style.top = document.documentElement.scrollTop + MarginTop; 
          document.getElementById("FloatDIV").style.left = document.documentElement.clientWidth - Width - MarginLeft; 
        } 
        setTimeout("Move();",100); 

    Set(); 
    Move(); 
    </script>
    <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><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>
    </body>
    </html>也可能是doctype的原因.试试上面的.