日期:2014-05-17  浏览次数:20804 次

真奇怪,给DIV.innerHTML赋值无效?
.
.
.
    var   vdiv=parent.document.getElementById( "disp ");
    vdiv.innerHTML= " <table> <tr> <td> 表格 </td> </tr> </table> ";
    alert(vdiv.innerHTML);
.
.
.

上面的代码没得显示,改成下面就可以
.
.
.
    var   vdiv=parent.document.getElementById( "disp ");
    vdiv.innerHTML= "表格 ";
    alert(vdiv.innerHTML);
.
.
.


------解决方案--------------------
<div id= "disp "> &nbsp; </div>
<script>
var vdiv = document.getElementById( "disp ");
vdiv.innerHTML= " <table> <tr> <td> 表格 </td> </tr> </table> ";
alert(vdiv.innerHTML);
</script>
------解决方案--------------------
<table> <tr> <td> <div id= "test "> </div> </td> </tr> </table>
<script language=javascript>
window.test.innerHTML= " <table> <tr> <td> aa </td> </tr> </table> "
</script>