PDA

View Full Version : child window & print option


ebco
11-26-2002, 07:30 AM
I have created one print link to print the page onclick of which i am calling chilld window to print with print dilogue box.

Now what I want is, if the user click cancel on that print dilogue box the window should close with print dilogue box.?

glenngv
11-26-2002, 07:45 AM
as far as I know, javascript can't determine if the user chooses print or cancel

ebco
11-26-2002, 08:46 AM
Is there any other way to determaine...

glenngv
11-26-2002, 09:18 AM
as far as i know, there is none. But even if there is a way, I would prefer not to auto-close the window. You don't know what the user prefers, maybe he wants to cancel the printing to see first what the page look like.

ebco
11-27-2002, 04:53 AM
I got the functionality which i want in this url

http://infotech.indiatimes.com/cms.dll/xml/comp/articleshow?artid=28861382

at the bottom article there is link of Print This Page.


But i did not understand how they done this?

glenngv
11-27-2002, 05:24 AM
you can view-source even if the Print dialog box is open.
This is their code:

<script language="javascript">
var i;
window.print();
setTimeout('window.close()',500);
</script>

That will close the window even if the user chooses Print or Cancel.

ebco
11-28-2002, 06:31 AM
In my given url they are not closing window after certain time.
I checked there code but it's quite difficult to understand what they have done?

:(

glenngv
11-28-2002, 08:11 AM
I've shown you THEIR code in my previous post. Did you try it?

ebco
12-20-2002, 11:33 AM
after long time

It's working fine I tried it today


Thanks glenngv

ebco
04-16-2003, 02:12 PM
one more query regarding this question :

<script language="javascript">
var i;
window.print();
setTimeout('window.close()',500);
</script>

I want to open it on click only not onload :

function xyz()
{
var printPage = window.open(xyz.htm);
printPage.blur();
printPage.print();
setTimeout(printPage.close(),600);
}

calling this function onclick. It is working onlything throwing error invalid argument setTimeout