【发布时间】:2010-03-02 17:49:50
【问题描述】:
我正在创建一个专门用于在 IE6 中打印的隐藏 iframe。
以下是删除了一些 HTML 填充的代码的基本大纲:
$('body').append('<iframe id="printIFrame"></iframe>');
$("iframe#printIFrame").attr('style','position:absolute;width:0px;height:0px;left:-500px;top:-500px;');
$("iframe#printIFrame").load(function()
{
document.getElementById("printIFrame").contentWindow.document.title = "My Title";
var iframe = document.getElementById("printIFrame");
iframe.contentWindow.focus();
iframe.contentWindow.print();
$("iframe#printIFrame").remove();
});
这工作得很好,除了在每个打印页面的左下角显示的丑陋的“about:blank”。我想因为我正在动态制作这个 iframe,所以源(如 IE6 所见)是关于:空白。有没有办法伪造 src 或更改那里打印的内容?我尝试在打印之前设置 src,但显然这会将 iframe 更改为新页面并打印出来。有什么想法吗?
【问题讨论】:
标签: iframe printing internet-explorer-6 src printing-web-page