1

I want to print only the content of multiple iframes in a webpage at once when print button is clicked.

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 i.e it prints first iframe and again click on print it prints second iframe.

But I want to print all the iframes at once when clicked on print button.

Arikael
  • 1,989
  • 1
  • 23
  • 60
Krishna
  • 11
  • 1

1 Answers1

0

this doesn't seem to be possible with Javascript (at least not in an easy or clean way)

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.

Arikael
  • 1,989
  • 1
  • 23
  • 60
  • Actual problem was printing fractions in a iframe , because it reads content from each iframe and fractions in mathquill woulkd appear like this $\frac{1}{2} (it should print as 1/2) . – Krishna Mar 12 '19 at 04:56
  • but this has nothing to do with what you asked – Arikael Mar 12 '19 at 06:42
  • Above mentioned printing fractions problem will come when content of every iframe is read and joined as you mentioned. When I added the above piece of code printing fractions problem was resolved but each iframe prints one after another . I want to print all the iframes at once when clicked on print button. – Krishna Mar 13 '19 at 04:31