简体   繁体   English

无法使用php,javascript在IE上打印iframe,而是打印当前页面,而不是有打印按钮

[英]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. 无法使用php,javascript在IE上打印iframe,打印当前页面而不是有打印按钮以及当我们点击打印按钮时它出现在index.php页面而不是它应该保留在打印当前页面上按钮存在。 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. 除了IE之外,所有的工作都适用于铬和火狐。 Please help me out with this problem. 请帮我解决这个问题。 Thanks in advance. 提前致谢。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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