简体   繁体   中英

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.

我也遇到了同样的问题,这个问题对我有用。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM