换个方式<script>
document.write("<iframe width=750 height=1100 frameborder=0 id=contentframe  src='about:'></iframe>");
contentframe.document.write("<img id=content border=0 width=700 src=123.jpg>");
</script>

解决方案 »

  1.   

    请问如果在IFRAME的SRC中指定一个1.html,1.html中有个IMG对象,请问如何在IFRAME中指定IMG对象的SRC呢,谢谢先!!
      

  2.   

    <script>
    document.write("<iframe width=750 height=1100 frameborder=0 id=contentframe  src='about:blank'></iframe>");
    contentframe.document.write("<img id=content border=0 width=700 src=123.jpg>");
    </script>
    src='about:'不会认为是一个空页面,IE会试图去NET上寻找该页面.结果当然是找不到.
    尽量不要用document.write.
    试用下面的方法:
    <script>
    oFrame=document.createElement("iframe width=750 height=1100 frameborder=0 id=contentframe")
    document.body.appendChild(oFrame)
    contentframe.document.loacation="about:blank"
    oImg=contentframe.document.createElement("img id=content border=0 width=700 src=123.jpg")
    contentframe.document.body.appendChild(oImg)
    </script>
    document.write其实只负责在当前语句位置写文本代码,容易页面代码不符合规范:如:
    <body>
    <table>
    <script>
    document.wirte("<img src='123.gif'>")
    </script>
    <tr>
    <td>
    </td>
    </tr>
    <table>
    </body>
      

  3.   

    window.frames['iframeName'].document.getElementById('imgID').src='1.jpg'name和id是不同的