【问题标题】:Unable to print an iframe on IE using php,javascript, prints current page instead in which there is print button无法使用 php、javascript 在 IE 上打印 iframe,而是打印当前页面,而不是其中有打印按钮
【发布时间】:2016-09-12 08:33:53
【问题描述】:

无法在 IE 上使用 php、javascript 打印 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 和火狐都可以正常工作。 请帮我解决这个问题。 提前致谢。

【问题讨论】:

    标签: javascript php jquery html iframe


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2013-07-08
      • 1970-01-01
      • 2015-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-17
      • 2011-06-05
      • 1970-01-01
      相关资源
      最近更新 更多