如何打印iframe中的内容 [英] How to Print iframe content
本文介绍了如何打印iframe中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何打印的iframe内的内容。在这个iframe网址网页也有一个更多的iframe中。
How to print iframe inner content. In this iframe URL page also having one more iframe.
我已经使用这个网址进入我的iframe中。
i have used this URL into my iframe.
<iframe width="700" height="500" src = "https://www.cashpayment.com/Public/PaymentCenterLocator?MerchantID=946">
我要打印此内容。
谢谢,
Somu
Thanks, Somu
推荐答案
试试这个,
var mywindow = window.open('', 'iFrameTagId', 'height=500,width=500');
mywindow.document.write('<html><head><title>title</title>');
mywindow.document.write('</head><body >');
mywindow.document.write(data);//iFrame data
mywindow.document.write('</body></html>');
mywindow.print();
mywindow.close();
或者你直接打开这个页面,并使用下面code,而页面加载
Or you directly open this page and use below code while page load
$(document).ready(function () {
window.print();
setTimeout('window.close();', 100);
});
更新code
function iprint(ptarget) {
var mywindow = window.open('', 'ptarget', 'height=500,width=500');
mywindow.document.write('<html><head><title>title</title>');
mywindow.document.write('</head><body >');
mywindow.document.write($(ptarget).html()); //iFrame data
mywindow.document.write('</body></html>');
mywindow.print();
mywindow.close();
}
<iframe name="theiframe" id="theiframe" width="700" height="500" src = "http://localhost:54649/WebSite6/Default.aspx"></iframe>
<input type="button" class="btninput" value="print iframe" onclick="iprint('#theiframe');" />
这篇关于如何打印iframe中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文