从隐藏的iframe打印页面 [英] Print page from hidden iframe
本文介绍了从隐藏的iframe打印页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在隐藏我要打印的页面时遇到问题。
I have problem hiding the page I want to print.
当我点击输入按钮时:
<input type="submit" id="print" name="print">
执行以下操作:
$(function(){
$('#print').click(function(){
if($('#bills_ID').val()==''){popUpMessage(Error);}
else { window.open('Bills/BillsPrint.php?bills_ID='+$('#bills_ID').val(), '_blank') }
});
});
并打印页面。此时我不想在打印时打开此页面Bills / BillsPrint.php。我只是希望打印而不显示页面。
and prints the page. At this point I do not want to open this page Bills/BillsPrint.php when printing. I simply want it print without displaying the page.
我如何通过使用隐藏的ifram来尝试这个
how can i try this by using hidden ifram
推荐答案
指定隐藏的 iframe
,如下所示:
Specify the hidden iframe
like this:
<iframe src="" style="display: none" id="myPrintView"></iframe>
并按如下方式使用jQuery:
And use jQuery as follows:
$('#print').click(function(e) {
e.preventDefault();
if($('#bills_ID').val()=='')
{
popUpMessage(Error);
}
else
{
$('#myPrintView').attr('src', 'Bills/BillsPrint.php?bills_ID='+$('#bills_ID').val());
$('#myPrintView').get(0).contentWindow.print();
}
});
你可以看到工作 jsFiddle here 。
You can see a working jsFiddle here.
这篇关于从隐藏的iframe打印页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文