【问题标题】:Cannot print in ie 11无法在ie 11中打印
【发布时间】:2019-02-26 20:46:50
【问题描述】:

我找到了这个打印解决方案:

  function Print() {
  if (document.queryCommandSupported('print')) {
document.execCommand('print', false, null);
  }
  else {
    window.parent.<framename>.focus();
    window.print();
  }
}

虽然我有几个 iframe 而不是只有一个。为多个 iframe 编写该代码的最佳方式是什么?

【问题讨论】:

  • 您的打印命令是从 iframe 执行的?
  • 没有。那就是问题所在。我当前的打印按钮适用于多个 iframe:
  • 函数 printall() { window.print(); for (var i=0; i
  • 我正在尝试合并 document.execCommand('print', false, null) 而不是我拥有的
  • 您的意思是要对每个 iframe 使用 document.execCommand() 方法,并逐个打印每个 iframe?

标签: javascript iframe printing internet-explorer-11


【解决方案1】:

在我看来,document.execCommand('print', false, null) 与 window.print() 方法类似,您可以使用它们中的任何一个来打印整个页面。

<script type="text/javascript">
    function printPage() {
        window.print();
        //document.execCommand('print', false, null);

        ////print each frames
        //for (var k = 0; k < window.frames.length; k++) {
        //    window.frames[k].focus();
        //    window.frames[k].print();
        //}
    }
</script>

【讨论】:

  • 这行得通。感谢你的回答。虽然我仍然无法不幸地在 ie 中打印到 pdf,正如我想的那样,将 window.print 替换为 document.execCommand
猜你喜欢
  • 1970-01-01
  • 2018-11-14
  • 2016-02-17
  • 2014-08-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-02
相关资源
最近更新 更多