【问题标题】:document.write() Only Displaying First Item in IE7, IE8document.write() 仅在 IE7、IE8 中显示第一项
【发布时间】:2012-10-12 00:49:41
【问题描述】:

我有一张图片,点击后会在新窗口中打开,显示较大的图片和打印按钮。我遇到的问题是新窗口仅显示 IE7 和 IE8 中的第一个 html 元素。切换语法的顺序证明了这一点。 document.write() 对于这种情况不正确吗?

<script type="text/javascript">
      function openWin()
      {
        var myWindow=window.open('','','width=855,height=885,scrollbars=yes,toolbar=yes');
        myWindow.document.write("<img src='/sites/default/files/PipelineChart_2012_large.jpg' height='785' width='835' style='float:left;' '/><input type='button' onClick='window.print()' value='PRINT'style='float:left; clear:both;'/>");

      }
    </script>

【问题讨论】:

    标签: javascript internet-explorer-8 internet-explorer-7


    【解决方案1】:

    在您的 document.write 调用中,您的 img 标签上的结束 /&gt; 之前有一个额外的引号:

    myWindow.document.write("
        <img src='/sites/default/files/PipelineChart_2012_large.jpg' height='785' width='835' 
            style='float:left;' />
        <input type='button' onClick='window.print()' value='PRINT'style='float:left; 
            clear:both;'/>");
    

    【讨论】:

    • 谢谢!我不会注意到这一点,尽管它是微不足道的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-14
    • 2018-12-05
    • 1970-01-01
    • 1970-01-01
    • 2015-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多