我正在創建專門用於在IE6中打印的隱藏iframe。假冒打印iframe的src以避免「about:空白」
這裏的一些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();
});
這是合作得非常好,除了醜陋「有關:空白」,顯示在每個左下方印頁。我猜想,因爲我正在做這個iframe的源(如IE6看到它)是關於:空白。有什麼方法來僞造src或改變在那裏打印的內容?我在打印之前嘗試設置src,但很明顯這會將iframe更改爲新頁面並將其打印出來。有任何想法嗎?