Failed to print iframe in IE using php, javascript, instead prints the current page that has a print button

It is not possible to print the iframe in IE using php, javascript, instead it prints the current page, which has a print button, and when we click the "Print" button, it is displayed on the index.php page, instead it should remain on the current page, in which there is a print button. 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 also tried in a different way, but did not work

 <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>

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

+4
source share
1

, , .

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

All Articles