简体   繁体   English

打印多个iframe内容

[英]Printing multiple iframe contents

I want to print only the content of multiple iframes in a webpage at once when print button is clicked. 单击打印按钮时,我一次只能打印网页中多个iframe的内容。

I already tried this code. 我已经尝试过此代码。

function printall() {
  window.print();
  for (var i=0; i<window.frames.length; i++) {

    window.frames[i].focus();
    window.frames[i].print();
  }
}

After adding this code , If i click on print it prints one by one ie it prints first iframe and again click on print it prints second iframe. 添加此代码后,如果我单击“打印”,它会一次打印,即它打印第一个iframe,然后再次单击“打印”,它打印第二个iframe。

But I want to print all the iframes at once when clicked on print button. 但我想在点击“打印”按钮时一次打印所有iframe。

this doesn't seem to be possible with Javascript (at least not in an easy or clean way) Javascript似乎无法做到这一点(至少不能以简单或简洁的方式)

But if you tell us a bit more about the desired output there may be another solution like reading the content of every iframe, join it together and then print it. 但是,如果您告诉我们有关所需输出的更多信息,则可能还有另一种解决方案,例如读取每个iframe的内容,将其结合在一起然后进行打印。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM