"the page was replaced while you was trying ..."

C

Carl

Hi,

I tried to print a document with the window.print method, but with netscape
7, i always get the error:"the page was replaced while you was trying to
print. Try again". I see "mydoc.htm" and the window of the printer appearing
on screen, but when clicking on 'ok' i get the error and 3 sec later,
'mydoc.htm' disappears.

With IE 6, no problem.

See the code: (even with setTimeout 20.000 it doesn't work)
yy="toolbar=no"
function printdoc()
{
opl=window.open("mydoc.htm","",yy)
opl.print()
setTimeout("opl.close()",3000)
}
document.getElementById("prt").onclick=printdoc

Thanks for any help
 
G

Grant Wagner

Carl said:
Hi,

I tried to print a document with the window.print method, but with netscape
7, i always get the error:"the page was replaced while you was trying to
print. Try again". I see "mydoc.htm" and the window of the printer appearing
on screen, but when clicking on 'ok' i get the error and 3 sec later,
'mydoc.htm' disappears.

With IE 6, no problem.

See the code: (even with setTimeout 20.000 it doesn't work)
yy="toolbar=no"
function printdoc()
{
opl=window.open("mydoc.htm","",yy)
opl.print()
setTimeout("opl.close()",3000)
}
document.getElementById("prt").onclick=printdoc

Thanks for any help

You can't print a window that contains no document, which is what is happening.
The loading of "mydoc.htm" is not instantaneous, it takes time, but you are
giving it no time to load before calling window.print().

IE may wait for the document to load before involving print() on it, or you
could just be lucky.

At any rate, you have to wait for the document in the new window to finish
loading before you can call print() on it. The simplest and best way to do this
is to add <body onload="window.print();"> to "mydoc.htm".

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 
D

Dave

thanks

Grant Wagner said:
You can't print a window that contains no document, which is what is happening.
The loading of "mydoc.htm" is not instantaneous, it takes time, but you are
giving it no time to load before calling window.print().

IE may wait for the document to load before involving print() on it, or you
could just be lucky.

At any rate, you have to wait for the document in the new window to finish
loading before you can call print() on it. The simplest and best way to do this
is to add <body onload="window.print();"> to "mydoc.htm".

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,249
Latest member
KattieCort

Latest Threads

Top