views:

309

answers:

2

I'm creating a hidden iframe specifically to be used for printing in IE6.

Here's a basic outline of the code with some HTML population cut out:

$('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();
});

This is working quite well, except for the ugly "about:blank" that shows at the bottom left hand of each printed page. I guess since I'm making this iframe on the fly the source (as IE6 sees it) is about:blank. Is there any way to fake the src or change what gets printed there? I tried setting the src right before printing, but obviously that changes the iframe to a new page and prints that. Any ideas?

A: 

You can not get this done without changing the src ahead of time, like you described. This is IE we're talking about. It's the single browser least likely to support anything fancy it could get away with not supporting.

(Though, for the record, I haven't heard of being able to override print metadata in any other browser, either.)

Matchu
A: 

I did find an ActiveX plugin which claims you can modify the header/footer of the printout on the fly.

http://www.meadroid.com/sx_intro.asp

Alternatively, it can be changed permanently by going to Page Setup from the File menu in IE6. However I'm trying to avoid an ActiveX plugin if possible; I'm wondering if there is an easy way to change the header or footer through javascript. Any other ideas?

macca1