Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

104 of 124 people (84%) answered Yes
Recently 7 of 10 people (70%) answered Yes


Why doesn't window.print() work in a child window which is opened using the method

Apr 5th, 2008 20:30
ha mo, Gerry Baldwin, Dangelo Sugar, Colin Fraser, Guest,

I am not convinvce the problem lies with the method, I think
that it is more likely that print() is being called wrongly.
Try this: 
<script language="JavaScript">
function SymError()
  return true;
window.onerror = SymError;
var childwin=new Object;
   childwin.location = childwin; 
   windowReference = childwin;  
The using a form : 
<input type="button" value="Print Child" onclick="if (window.print)
You will have to change this to suit your particular need, but this
should provide a working solution
Actually, the problem lies in the child window not the actual print().
to solve the problem.
newWindow = \\opening child window
newWindow.location.reload( false ); \\ refreshes the child window
\\ for some reason, the child window has to be refreshed
\\ *** in child window ***
<input type=button onclick='window.print();'>
This should do the TRICK!!!
The window.print() command stalls because the new window is still open 
for input. If one closes with windowName.document.close(); the print 
command works as expected.
Try this:
<TITLE>Print Child Window</TITLE>
function printChildWindow() {
	var newWindow =
("newWindow.html", "newWindow", "height=200,width=300");
Daughter</TITLE></HEAD><BODY><CENTER><BR><BR>This is some 
data.<BR><BR><BR><INPUT TYPE="button" NAME="print" VALUE="Click to 
Print" ONCLICK="window.print()"></CENTER></BODY></HTML>');
	newWindow.document.close(); //This is the key!!!
<INPUT TYPE="button" VALUE="Click to Create New Window"