Swati Dhamale Swati Dhamale - 6 months ago 28
jQuery Question

Unable to print an iframe on IE using php,javascript, prints current page instead in which there is print button

Unable to print an iframe on IE using php,javascript, prints current page instead in which there is print button
as well as, when we click on print button it comes out to index.php page instead it should stay on current page in which print button exists.
my code is as follows.

<iframe id="frame1" src="splits-sorting-print.php" name="frame1" style="display:none;"></iframe>

<a href="javascript:void(0);" onclick="frames['frame1'].print()" class="btn btn-back" ><i class="fa fa-print"></i>Print</a>


I have tried with other way also but didn't worked

<script type="text/javascript">
function printie()
{
try
{
iframe = document.getElementById('frame1');
iframe.contentWindow.document.execCommand('print', false, null);
}
catch(e)
{
window.print();
}
}
</script>


<a href="javascript:void(0);" onclick="printie();" class="btn btn-back" ><i class="fa fa-print"></i>Print</a>


All works fine with chrome and fire fox except IE.
Please help me out with this problem.
Thanks in advance.

Answer

I had also the same issue I have tried this and it worked for me.

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11"/>
Comments