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

标签 javascript php jquery html iframe

无法使用 php、javascript 在 IE 上打印 iframe,而是打印当前页面,其中有打印按钮 以及,当我们点击打印按钮时,它会出现在 index.php 页面上,而不是它应该停留在存在打印按钮的当前页面上。 我的代码如下。

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

我也试过其他方法,但没用

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

除 IE 外,其他一切都适用于 chrome 和 fire fox。 请帮我解决这个问题。 提前致谢。

最佳答案

我也遇到了同样的问题,我已经尝试过了,它对我有用。

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

关于javascript - 无法使用 php、javascript 在 IE 上打印 iframe,而是打印当前页面,其中有打印按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37255848/

相关文章:

php - 将表单结果发布到 COLORBOX 模式中

java - 如何将整数数组传递给 spring Controller ?

javascript - 如何将参数传递给 "then"函数

javascript - 使用 jquery/javascript 动画 slider

php - 根据以下列出列中的所有日期

php - 如何在 Wordpress 中设置类别标题的样式?

javascript - 如何隐藏被单击按钮上的面板?

javascript - 在 Codeigniter 中自动刷新 div

JavaScript 复选框数组

javascript - 从对象数据生成表