darcosys
asked on
Print a pop-up window
I want to print a page but with this steeps.
1.- Open a window
2.- When the page load complete , print the page.
3.- Close the window.
there are some event like onfinishload then i can call the function print
1.- Open a window
2.- When the page load complete , print the page.
3.- Close the window.
there are some event like onfinishload then i can call the function print
ASKER
ok, that's great but , now , how can i close the pop up window.
I tried this onafterprint="window.close ()" but it doesn't work.
I tried this onafterprint="window.close
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I don't see why you want a popup that print then close itself.. The user does any interaction in this window?
You know that if it is just because you want to print something different that the current page you are on (like a different content). There is a clean way to do it with CSS. With media="print"...
You know that if it is just because you want to print something different that the current page you are on (like a different content). There is a clean way to do it with CSS. With media="print"...
ASKER
i'm developing on asp.net then, when i save the data i call the window for print a report
something like window.open('report_print. ......') i only want this page for print the report, i don't have javascript code, only fill the report and i want to print (that's ok) but the window keep opened.
sorry my grama but i don't speak english very well :)
thanks a lot, it work ( self.setTimeout('window.cl ose()', 5000); )
something like window.open('report_print.
sorry my grama but i don't speak english very well :)
thanks a lot, it work ( self.setTimeout('window.cl
ASKER
<body leftmargin="0" topmargin="0" onload="prnt()">
function prnt(){
window.print()
self.setTimeout('window.cl ose()', 5000);
}
function prnt(){
window.print()
self.setTimeout('window.cl
}
The set timeout is pretty useless if you don't want the user to really see the page.. you can do
<body leftmargin="0" topmargin="0" onload="prnt()">
function prnt(){
window.print()
window.close()
}
The javascript will wait after the user decision about printing or not before closing.
<body leftmargin="0" topmargin="0" onload="prnt()">
function prnt(){
window.print()
window.close()
}
The javascript will wait after the user decision about printing or not before closing.
I'm glad I could help. Thanks for the grade, the points and the fun question.
You should keep the timeout. Just answering the prompt to print won't provide enough time for the browser to process and get the page to the spooler. The popup will need to be up for at least a few seconds, even with the most simple of pages.
bol
You should keep the timeout. Just answering the prompt to print won't provide enough time for the browser to process and get the page to the spooler. The popup will need to be up for at least a few seconds, even with the most simple of pages.
bol
Use onload. Is the content or page in the popup on your server and domain? Can you add code to it or do you want the main (opener) window to do this?
The simplest method is in the body tag in the html for the popup. Call the print function.
<body onload="window.print();">
Let me know if you have any questions or need more information.
b0lsc0tt