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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Intermittent error on printing 1

Status
Not open for further replies.

patwadd

Programmer
Nov 29, 2000
6
GB
I have two pages that run one after the other, both of which automatically print on load without any user intervention (except their printer box). Very occasionally the following message appears on the second page:

Error: The caller (server[not server application]) is not available and disappeared; all connections are invalid. The call did not execute.

The code on the line in question is:

window.print()

Is this an IE6 problem related to the printing or some oddity in the code?

Thanks
 
I don't mean to hijack this post, but how do you get the users print box to open up as soon as the html page has loaded??

Thats exactly what im looking for

Soph
 
My thanks to all who replied.

This is the code in the first page:

function Autoprint()
{
window.print();
location.replace("RentalAgreement2.asp");
}
.
.
<body oncontextmenu="return false;" onLoad="Autoprint()">

and this is the code in the second page (RentalAgreement2.asp)

function Autoprint()
{
window.print();
location.replace("PrintMenu.asp");
}
.
.
<body oncontextmenu="return false;" onLoad="Autoprint()">

trollacious - as you can see, the printing is the first statement in the onLoad function

sophielois - the user's print window opens without me doing anything. Depending on what else is going on, it sometimes takes a few seconds for it to open. Because there are two pages, two print windows open.

It's OK virtually all the time. My own feeling is that possibly the location.replace statement is being executed before the print output has been fully buffered and so the operating system perceives a lost connection.

I had to do it this way because a) the user wanted the pages printed automatically and b) there is no way I have found to force a page break that works

Pat
 
If the amount of content on page 1 isn't overly big, you could fudge it by putting the location assignment in a setTimeout call, giving a delay of maybe 10-15 seconds or so for the printout to finish.

Not perfect, I know... but with the little control you have over printing in JS, it's probably the best you can do.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top