【问题标题】:How to print pdf in iframe using javascript in ie6?如何在 ie6 中使用 javascript 在 iframe 中打印 pdf?
【发布时间】:2011-08-20 06:59:21
【问题描述】:

我在 iframe 中显示了一个 pdf,它位于 aspx 页面中。我正在开发 IE6 浏览器。我使用以下 html 和 javascript 代码。

<iframe id = "frame_singleCheque" src = "../pdf/SingleCheque.pdf" runat = "server" style ="height:400px; width: 750px; overflow:scroll;" />


function printDoc()
{
      window.frames['ctl00_contPlcHdrMasterHolder_frame_singleCheque'].focus();
      window.frames['ctl00_contPlcHdrMasterHolder_frame_singleCheque'].print();
}

<input type="button" id = "btnCPrint" value = "Print" onclick="javascript:printDoc()" />

如果按下打印按钮,它会显示打印对话框。但是每当我按下打印按钮时,它都不会打印任何东西。它不会将事件打印为空白页。如何打印?

【问题讨论】:

标签: javascript


【解决方案1】:

试试这个:

function printDoc() {
   document.getElementById('frame_singleCheque').focus(); 
   document.getElementById('frame_singleCheque').contentWindow.print();
}

编辑:也可以查看this

【讨论】:

  • 亲爱的 Behrang Saeedzadeh,我已经用过这个了。但它会打印除 iframe 部分之外的整个页面。
  • @Mahedee:你确定你也包括contentWindow 吗?在您的代码中,您没有指定contentWindow
猜你喜欢
  • 2011-11-21
  • 2014-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-10
  • 1970-01-01
相关资源
最近更新 更多