创建html页面并在javascript中打印到新标签页 [英] create html page and print to new tab in javascript
本文介绍了创建html页面并在javascript中打印到新标签页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建html页面为内联,该页面打开到新标签并显示打印视图
create html page as inline and that page open to new tab and show print view
我尝试使用此代码但无法正常工作..
i tried with this code but not working..
var mywindow = window.open('', 'Print Report', 'height=400,width=600');
mywindow.document.write('<html><head><title>Print Report</title>');
mywindow.document.write('</head><body ><table border="1" style="width: 500px; height: 300px;">');
mywindow.document.write(htmlTable);
mywindow.document.write('</table></body></html>');
mywindow.open().print();
推荐答案
试试这个..
var winPrint = window.open('', '', 'left=0,top=0,width=800,height=600,toolbar=0,scrollbars=0,status=0');
winPrint.document.write('<title>Print Report</title><br /><br /> Hellow World');
winPrint.document.close();
winPrint.focus();
winPrint.print();
winPrint.close();
如果窗口未打开..请检查弹出窗口是否被阻止:).. ..
if the window is not open .. please check whether the popup is blocked :)..
这篇关于创建html页面并在javascript中打印到新标签页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文