Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

Printing an iframe with pdf using javascript is not working in IE8 and above

$
0
0

I have a problem with printing and Iframe with PDF in IE 8 and above

Following is my javascript:

var urlValue="";//Path of the file to be printed

var div = document.getElementById("printerDiv");
div.innerHTML = '<iframe src="' + urlValue + '" id="frame" name="frame" style="width:100%;height:100%;"></iframe>';

frame.focus();
frame.print();

This same thing is working fine in other browser but for IE is just not invoking the print dialog.

Also I tried to get the frame.print(); on load of the frame but even that is not working exactly as that way it print the parent window in output.

Few things I tried like:

1) div.innerHTML = '<iframe src="' + urlValue + '" onload="this.contentWindow.print();"></iframe>';

2) frame.contentWindow.focus();
frame.contentWindow.print();

3) window.document.getElementsByTagName('iframe')['frame'].onload = (function () {

frame.focus();

frame.print();

});


I need to get the print of only the content which is in Iframe which I am binding in "printerDiv" by javascript.

Any perfect/different solution from which I have tried then please post here?

Thanks.


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>