PDA

View Full Version : close after print


thickandthin
08-17-2002, 01:03 AM
hi i have a question about a popup window that closes after you

print because i have coupons and right when they print i want it

to close, and i have cookies so that they could come back in 1

week.........help!!!!!!!!



alessandro

beetle
08-17-2002, 04:48 AM
Ok, before I help...let me make sure I'm answering the right question. You have a popup window with coupons in it. When the page is printed you want to close the window and store a cookie that expires in 1 week. During that week (while the cookie exists) they cannot print (or view) the popup page again?

thickandthin
08-17-2002, 04:44 PM
i already have the cookie that expires in 1 week but i need the

close after print really bad, thanks, post back!

,alessandro

beetle
08-17-2002, 11:15 PM
<script>
window.onAfterPrint = setTimeout('top.close();',5000);
</script>

Closes window 5 seconds after print command is sent to printer.

This will probably only work in IE5+

thickandthin
08-18-2002, 12:10 AM
Sorry beetle i tried it out but it closes after 5 seconds if you click

print or not, basicly once you open it, it closes after 5 seconds.

beetle
08-18-2002, 01:03 AM
Sorry, that method is JScript only. Here, try this for better compatibility

<body onAfterPrint="setTimeout('top.close();',5000);">

jkd
08-18-2002, 01:55 AM
Originally posted by beetle
<script>
window.onAfterPrint = setTimeout('top.close();',5000);
</script>

Closes window 5 seconds after print command is sent to printer.

This will probably only work in IE5+

I would imagine that isn't working because you aren't assigning it a function:

window.onafterprint = function() {
setTimeout('top.close()', 5000);
}