您可以使用隐藏的 iframe 来完成此操作(我以jquery为例):
function loadOtherPage() { $("<iframe>") // create a new iframe element .hide() // make it invisible .attr("src", "/url/to/page/to/print") // point the iframe to the page you want to print .appendTo("body"); // add iframe to the DOM to cause it to load the page}这将加载您要打印的页面。要进行打印,可以将javascript代码添加到打印页面,以便在加载后将其打印出来:
$(document).ready(function () { window.print();});这将打印页面而不显示新窗口。我已经在IE8,9和Google Chrome浏览器中对此进行了测试,因此我不确定这是否适用于Safari或Firefox。



