Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

page doesn't print if close fn is immdtly called

Status
Not open for further replies.

samasamajam

Programmer
Dec 27, 2002
13
GB
I have a requirement where i have to print the page contents in a printable format. For this i have to open the printable format in a new window and issue the print command.
i am using window.open for opening teh new window. In the body tag of the new window i have the following code..
<body onload="javascript:window.print()" onfocus="javascript:window.close()">
With this code i print the page and close the window. This works fine with IE. But with netscape 7.1 the print doesn't work. This is bcoz the window.close is being called even before the print spooling happens. COuld anyone help me with this where i can ensure that spooling of data is complete.
 

The "javascript:" is not necessary. Try adding a delay to the close function:

Code:
<body onload="window.print();" onfocus="setTimeout('window.close()', 5000);">

This will add a 5 second delay before closing the window.

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top