无法使用 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/