PDA

View Full Version : Dialog - Iframe -Printing



crouchg
10 May 2007, 9:32 PM
I have an Iframe in the body of a dialog....




if(!printdialog)
{
var y = Ext.DomHelper.append(document.body, {id:'printBox', tag: 'div'}, true);
printdialog = new Ext.BasicDialog(y, {
width: 800,
height: 600,
shadow: true,
modal : false,
resizable : false,
closable : true,
collapsible : false
});

printdialog.addKeyListener(27, printdialog.hide, printdialog);
printdialog.addButton('Print', printThisContent, thisCopy);
printdialog.addButton('Close', printdialog.hide, printdialog);
}
printdialog.setTitle('Print Results');
printdialog.body.dom.innerHTML = '<iframe name=printIframe id=printIframe frameborder=0 style=width:100%;height:100%></iframe>';
printdialog.show(item.dom);



I then try to print the Iframe content after adding some coentent....




function printContent()
{
printIframe.document.write('<html>' + document.getElementsByTagName('head')[0].outerHTML + '<body id=printBody onload="window.print();">'+ document.getElementById('cgtDetailTable').outerHTML +'</body></html>');
}

function printThisContent()
{
printIframe.print();
}



Something seems to be getting in the way? Is the Dialog box keeping the Print Dialog from getting focus.

Any help Please?

crouchg
13 May 2007, 9:10 PM
Hi Jack, Do you have any code keeping the Dialog in focus that does not allow the print dialog to come to the front?

crouchg
15 May 2007, 2:44 PM
This is a IE vs FF problem

In firefox window.frams['framename'].print() works

in IE

window.frams['framename'].focus()
window.print()

works, I believe this is because of the difference in how the print dialogs behave once window.print is called, in FF it always prints the document of the current window/frame which is why its necessary to explicitly run print on that frame. Where as in IE it prints the currently focus frame selecting the "Only Selected Fames" on the options tab of the print dialog. So first focusing the target printing frame them window.print(), comes out with the correct outcome in IE.