<td><div style="width:100%;height:100%"></div></td>

解决方案 »

  1.   

    我需要在说明一下,DIV是浮动在<TD></TD>之上的而不是<td><div></div></td>这样的关系!!!
      

  2.   

    层的长宽根据实际情况做些修正即可
    ------------------------------------------
    <style>
      div.float {
      background:transparent;
      position:absolute;
      z-index:99;
      star : expression(this.style.left = getPositionX(this.t), this.style.top = getPositionY(this.t), this.style.width = eval(this.t).clientWidth, this.style.height = eval(this.t).clientHeight)
      }
    </style>
    <script>  
      function getPositionX(t)
      {
        var obj = eval(t)
        var x = obj.offsetLeft
        while(obj = obj.offsetParent)
        {
          x += obj.offsetLeft
        }
        return x
      }
      function getPositionY(t)
      {
        var obj = eval(t)
        var y = obj.offsetTop
        while(obj = obj.offsetParent)
        {
          y += obj.offsetTop
        }
        return y
      }
    </script><div class="float" t=td1 style="border:1px red solid;">&nbsp;&nbsp;&nbsp;&nbsp;456</div>
    <div class="float" t=td2 style="border:1px blue solid;">&nbsp;&nbsp;&nbsp;&nbsp;456</div>
    <table border="1" bgcolor=#efefef>
    <tr>
      <td width="120" height="22" id="td1">123&nbsp;</td>
      <td width="130" id="td2">123&nbsp;</td>
    </tr>
    </table>
      

  3.   

    again
    ----------------------
    <style>
      div.float {
      background:transparent;
      position:absolute;
      z-index:99;
      star : expression(this.style.left = getPositionX(this.t), this.style.top = getPositionY(this.t), this.style.width = eval(this.t).clientWidth+1, this.style.height = eval(this.t).clientHeight+2)
      }
    </style>
    <script>  
      function getPositionX(t)
      {
        var obj = eval(t)
        var x = obj.offsetLeft
        while(obj = obj.offsetParent)
        {
          x += obj.offsetLeft
        }
        return x
      }
      function getPositionY(t)
      {
        var obj = eval(t)
        var y = obj.offsetTop
        while(obj = obj.offsetParent)
        {
          y += obj.offsetTop
        }
        return y
      }
    </script><div class="float" t=td1 style="border:1px red solid;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;456</div>
    <div class="float" t=td2 style="border:1px blue solid;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;456</div>
    <table border="1" bgcolor=#efefef>
    <tr>
      <td width="120" height="22" id="td1">123</td>
      <td width="130" id="td2">123&nbsp;</td>
    </tr>
    </table>
    <input type="button" onclick="td1.innerText=td1.innerText=='123'?'层的长宽根据实际情况做些修正即可':'123'" value="click">
      

  4.   

    star : expression
    t=td1
    这两句我理解不到
      

  5.   

    var y = obj.offsetTop
        while(obj = obj.offsetParent)
        {
          y += obj.offsetTop
        }
    为什么取得了td1.offsetTop之后,DIV还不能直接定位到td1上去,还要做y+=td1.offsetTop的运算呢?
      

  6.   

    expression为CSS的自定义属性,在属性里写需要的代码,就可以结合CSS的特性与JS特效
    t=td1 也是利用了自定义属性,目的是用来配置层对应的单元格的id
      

  7.   

    offsetTop/offsetLeft 这组属性的值都是相对的(relative to the layout or coordinate parent),所以要迭代到文档的顶层元素
      

  8.   

    大侠帮我指点一下,为什么我下边的代码不能完全浮动的重合在<td id="imgch">上
    说明:imgch是一个td的id
    <script>
    onload=function changeimg()
    {
    var x=0;
    var y=0;
    var obj=document.all.imgch;
    while(obj.offsetParent!=null)
    {
    obj=obj.offsetParent;
    x+=parseInt(document.all.imgch.offsetLeft);
    y+=parseInt(document.all.imgch.offsetTop);
    }document.all.jsjs.style.width=document.all.imgch.clientWidth;
    document.all.jsjs.style.height=document.all.imgch.clientHeight;document.all.jsjs.style.left=x;
    document.all.jsjs.style.top=y;
    x=0;
    y=0;}
    </script>
    <body style="LEFT: 0px; FLOAT: right; WIDTH: 772px; POSITION: absolute; TOP: 0px" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" MS_POSITIONING="GridLayout">
    <div id="jsjs" style="COLOR: #660033; POSITION: absolute; BACKGROUND-COLOR: #ffcc66"></div>
            <table width="772" height="100" border="0" align="center" cellpadding="0" cellspacing="0"
                id="Table1" name="Table1">
                <tr>
                    <td colspan="2" align="center"><img src="./images/aa.gif" width="772" height="95"></td>
                </tr>
                <tr align="center" valign="middle">
                    <td width="101" height="79" align="center" style="BORDER-RIGHT:0px; BORDER-TOP:0px; BORDER-LEFT:0px; BORDER-BOTTOM:0px"><img src="" id="img1" width="100" height="90">
                    </td>
                    <td id="imgch" width="671">
                        <OBJECT codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
                            height="100%" width="100%" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>
                            <PARAM NAME="_cx" VALUE="16748">
                            <PARAM NAME="_cy" VALUE="2487">
                            <PARAM NAME="FlashVars" VALUE="">
                            <PARAM NAME="Movie" VALUE="wbt.swf">
                            <PARAM NAME="Src" VALUE="wbt.swf">
                            <PARAM NAME="WMode" VALUE="Window">
                            <PARAM NAME="Play" VALUE="-1">
                            <PARAM NAME="Loop" VALUE="-1">
                            <PARAM NAME="Quality" VALUE="High">
                            <PARAM NAME="SAlign" VALUE="">
                            <PARAM NAME="Menu" VALUE="-1">
                            <PARAM NAME="Base" VALUE="">
                            <PARAM NAME="AllowScriptAccess" VALUE="always">
                            <PARAM NAME="Scale" VALUE="ShowAll">
                            <PARAM NAME="DeviceFont" VALUE="0">
                            <PARAM NAME="EmbedMovie" VALUE="0">
                            <PARAM NAME="BGColor" VALUE="">
                            <PARAM NAME="SWRemote" VALUE="">
                            <PARAM NAME="MovieData" VALUE="">
                            <PARAM NAME="SeamlessTabbing" VALUE="1">
                            <embed src="wbt.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
                                type="application/x-shockwave-flash" width="100%" height="100%"></embed>
                        </OBJECT>
                    </td>
                </tr>
    </table>
      

  9.   


    <script>
    onload=function changeimg()
    {
      var obj=document.all.imgch;
      var x=obj.offsetLeft;
      var y=obj.offsetTop;
      while(obj.offsetParent!=null)
      {
      obj=obj.offsetParent;
      x+=obj.offsetLeft;
      y+=obj.offsetTop;
      }
      
      document.all.jsjs.style.width=document.all.imgch.clientWidth+2;
      document.all.jsjs.style.height=document.all.imgch.clientHeight+2;
      
      document.all.jsjs.style.left=x;
      document.all.jsjs.style.top=y;
      x=0;
      y=0;
    }
    </script>
    <body style="LEFT: 0px; FLOAT: right; WIDTH: 772px; POSITION: absolute; TOP: 0px" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" MS_POSITIONING="GridLayout">
    <div id="jsjs" style="COLOR: #660033; POSITION: absolute; BACKGROUND-COLOR: #ffcc66; border:1px solid blue"></div>
            <table width="772" height="100" border="0" align="center" cellpadding="0" cellspacing="0"
                id="Table1" name="Table1">
                <tr>
                    <td colspan="2" align="center"><img src="./images/aa.gif" width="772" height="95"></td>
                </tr>
                <tr align="center" valign="middle">
                    <td width="101" height="79" align="center" style="BORDER-RIGHT:0px; BORDER-TOP:0px; BORDER-LEFT:0px; BORDER-BOTTOM:0px"><img src="" id="img1" width="100" height="90">
                    </td>
                    <td id="imgch" width="671" style=" border:1px solid red">
                        &nbsp;
                    </td>
                </tr>
    </table>
      

  10.   

    我其实是想在<td></td>中的flash上朦一层透明的div,再在这个div 上显示一些文字.现在这个层虽然完全的重合在了flash上,但为什么这个div却没有在最上面一层呢?
    应该如何做,才能让这个div浮在flash之上??
      

  11.   

    可以通过在层中放一个iframe来解决
    ----------------------------------------
    <script>
    onload=function changeimg()
    {
      var obj=document.all.imgch;
      var x=obj.offsetLeft;
      var y=obj.offsetTop;
      while(obj.offsetParent!=null)
      {
        obj=obj.offsetParent;
        x+=obj.offsetLeft;
        y+=obj.offsetTop;
      }
      
      document.all.jsjs.style.width=document.all.imgch.clientWidth+2;
      document.all.jsjs.style.height=document.all.imgch.clientHeight+2;
      
      document.all.jsjs.style.left=x;
      document.all.jsjs.style.top=y;
      ifm.document.open()
      ifm.document.close()
      ifm.document.write ("<span style='color:red;width:100%;height:100%;text-align:center;vertical-align:middle;'>文字</span>")
      x=0;
      y=0;
    }
    </script>
    <body style="LEFT: 0px; FLOAT: right; WIDTH: 772px; POSITION: absolute; TOP: 0px" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" MS_POSITIONING="GridLayout">
    <div id="jsjs" style="COLOR: #660033; POSITION: absolute; BACKGROUND-COLOR: #ffcc66; border:1px solid blue">
    <iframe id="ifm" src="" border=0 frameborder=0 style="width:100%;height:100%"></iframe>
    </div>
            <table width="772" height="100" border="0" align="center" cellpadding="0" cellspacing="0"
                id="Table1" name="Table1">
                <tr>
                    <td colspan="2" align="center"><img src="./images/aa.gif" width="772" height="95"></td>
                </tr>
                <tr align="center" valign="middle">
                    <td width="101" height="79" align="center" style="BORDER-RIGHT:0px; BORDER-TOP:0px; BORDER-LEFT:0px; BORDER-BOTTOM:0px"><img src="" id="img1" width="100" height="90">
                    </td>
                    <td id="imgch" width="671" style=" border:1px solid red">
                    <param name="wmode" value="opaque"><embed src="http://images.csdn.net/20050809/news_channel_banner_468x6001.swf" quality=high width="100%" height="90"></embed>
                    </td>
                </tr>
    </table>
    <button onclick="aa()">click</button>
    <script>
    function aa()
    {
      if(jsjs.children.length>0)
      {
        jsjs.removeChild(jsjs.children[0])
      }
      else
      {
        jsjs.innerHTML = '<iframe id="ifm" src="" border=0 frameborder=0 style="width:100%;height:100%"></iframe>';
        ifm.document.write ('<span style="color:red;width:100%;height:100%;text-align:center;vertical-align:middle;">文字</span>')
      }
    }
    </script>
      

  12.   

    大侠是不是让一个层包含一个iframe后
    与<td></td>中的flash交替显示在下想要的效果是让div中显示出文字,然后朦在flash上,或者说是flash与div 同时显示