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
Asked
Active
Viewed 2.5k times
1

Community
- 1
- 1

Muxiddin Jumaniyazov
- 57
- 1
- 1
- 5
1 Answers
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:
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;
}
-
I'm all ready tried but it didn't work.I need another solution – Muxiddin Jumaniyazov Sep 05 '14 at 10:16
-
Your solution works in Chrome but not in (at least) IE11, didnt try other browsers. In IE11, It's printing the outerwindow and the iframe – Sajjan Sarkar Aug 08 '18 at 12:10