[thelist] JavaScript: Print Then Close

Sarat Pediredla sarat.pediredla at gmail.com
Thu Jan 12 15:01:42 CST 2006

> It's all working but closing the new window:

(Note: Sorry for the copy pasted code. It is quite small and hence I
took the liberty of pasting it)
Try this in the "parent" window (the window which opens the popup).


<body onLoad="openpage();">
<script language="JavaScript"><!--
function openpage()
if (msgWindow.opener == null) msgWindow.opener = self;

and then in the child/popup window

 <title>Page to Print</title>
<body onload="printpage()">
<script language="Javascript">
function printpage() {
Text Here

I have tested this in IE but I dont see why it shouldnt work on others.

Finally, I have to make a point about unobtrusive javascript. Using
onLoad inside tags defeats the point of usability or good coding. I
feel a bit evangelical these days , so I will refer you to
http://www.webstandards.org without further ado.
Sarat Pediredla
Blog: http://sarat.xcelens.co.uk "Talking a lot about nothing"

More information about the thelist mailing list