1

I want to print iframe content and I could not do it, I found the url I'm a new promgrammer so i didn't understant the question and answers please explane me a few simple
thanks in advance

Community
  • 1
  • 1

1 Answers1

6

Here it is :

Your iframe :

<iframe id="printf" name="printf"></iframe>

Printing :

window.frames["printf"].focus();
window.frames["printf"].contentWindow.print();

BTW, try to explain your problem in a better way next time (posting code can help) =)

Ref : Javascript Print iframe contents only

EDIT :

As OP said didn't work, i'm referring the testpage which was linked in Ref:

Print an iframe

You can also try this function (same ref, different poster) :

//id is the  id of the iframe
function printFrame(id) {
            var frm = document.getElementById(id).contentWindow;
            frm.focus();// focus on contentWindow is needed on some ie versions
            frm.print();
            return false;
}
Jonny-W
  • 33
  • 5
Hotted24
  • 502
  • 3
  • 8