I had a similar problem about a month ago, try loading what you want to print into an iframe <iframe> and using JavaScript to print only that iframe:
Code:
// Function to print out a page that has not been
// loaded onto the screen
function printURL (url) {
if (window.print && window.frames && window.frames.printerIframe) {
var html = '';
html += '<html>';
html +=
'<body onload="parent.printFrame(window.frames.urlToPrint);">';
html += '<iframe name="urlToPrint" src="' + url + '"><\/iframe>';
html += '<\/body><\/html>';
var ifd = window.frames.printerIframe.document;
ifd.open();
ifd.write(html);
ifd.close();
}
else {
if (confirm('To print a page with this browser ' +
'we need to open a window with the page. Do you want to continue?'))
{
var win = window.open('', 'printerWindow',
'width=600,height=300,resizable,scrollbars,toolbar,menubar');
var html = '';
html += '<html>';
html +=
'<frameset rows="100%, *" ' +
'onload="opener.printFrame(window.urlToPrint);">';
html += '<frame name="urlToPrint" src="' + url + '" \/>';
html += '<frame src="about:blank" \/>';
html += '<\/frameset><\/html>';
win.document.open();
win.document.write(html);
win.document.close();
}
}
}
function printFrame (frame) {
if (frame.print) {
frame.focus();
frame.print();
}
}
www.crmpicco.co.uk