I am trying to open a window dynamically, filling it with data from a table on another window and then printing the new window. The window.print() and self.print() do nothing. Here's my code:
Everything else works fine, including the "Close Window" link. AND if I replace window.print() with window.close() in the controls variable, the window closes fine. So, I can't see anything with the code that's wrong. It must be with print(). Oh, the Print button on the browser window is active and visible and clicking on it prints the window as it should (brings up the print dialog box and allows printing).
Thoughts? Is this a security issue? HELP!
Just FYI, I'm not printing from the main window because it contains stuff I don't want on paper. If I put the print button on the main window, it works fine.
TIA,
DreamerZ
Code:
function dailyPrint()
{
var entry = window.open('','_blank','resizable=yes,toolbar=yes,scrollbars=yes,height=600,width=700');
var controls = '';
var output = '<b>Entries for: ' + document.getElementById('entry_TodayDate').value + '</b><BR>\\n'
+ document.getElementById('entry_Daily').innerHTML
+ '\\n<BR><BR><i>Click \'PRINT\' on the browser window to print this page.<br>\\n'
+ '<BR><a href=\'javascript:void\' onclick=\'window.close()\'>Close Window</a><BR>\\n';
controls += '<input type=button value=Print onclick=\'window.print()\' >';
entry.document.open();
entry.document.write(output+controls);
}
Everything else works fine, including the "Close Window" link. AND if I replace window.print() with window.close() in the controls variable, the window closes fine. So, I can't see anything with the code that's wrong. It must be with print(). Oh, the Print button on the browser window is active and visible and clicking on it prints the window as it should (brings up the print dialog box and allows printing).
Thoughts? Is this a security issue? HELP!
Just FYI, I'm not printing from the main window because it contains stuff I don't want on paper. If I put the print button on the main window, it works fine.
TIA,
DreamerZ