faqts : Computers : Programming : Languages : JavaScript : Windows

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 34 people (50%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

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

Mar 6th, 2004 23:23
Gerry Baldwin, Guest,


<HTML>
<HEAD>
<TITLE>Print Child Window</TITLE>
<SCRIPT>
function printChildWindow() {
	var newWindow = window.open
("newWindow.html", "newWindow", "height=200,width=300");
	newWindow.document.write('<HTML><HEAD><TITLE>Print 
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!!!
	}
</SCRIPT>
</HEAD>
<BODY>
<CENTER>
<BR><BR><BR>
<INPUT TYPE="button" VALUE="Click to Create New Window" 
ONCLICK="printChildWindow();">
<CENTER>
</BODY>
</HTML>