Die Page, Die! (Was: Preview button to show PDF without submitting post data?)

From: Date: Sun, 08 Nov 2009 12:38:48 +0000
Subject: Die Page, Die! (Was: Preview button to show PDF without submitting post data?)
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-299695@lists.php.net to get a copy of this message
PHP List, Okay, so I've got a nice situation where a form has a preview button as well as a submit button. When the user presses "Submit", the page reloads, and it emails a PDF. If the user presses "Preview", it launches a new page in a new window, and also outputs a PDF directly to the user so they can review it. All good, but I don't need that second window open once the PDF has been shown to the user. For some reason I can't kill that second window. I've tried two methods. Killing it with PHP, and killing it with JavaScript. Here's the PHP version: if (isset($_POST['preview'])) { $pdf->Output("preview.pdf", "D"); die("PDF プレビュー出しました / PDF Preview Displayed"); } Here's the JavaScript version: if (isset($_POST['preview'])) { $pdf->Output("preview.pdf", "D"); echo '<script type="text/javascript">javascript:self.close();</script>'; } But in either case, I keep getting that second page coming out, with the whole form rendered all over again. How can I kill a page? Once the PDF is rendered, I don't need it. I'd be okay if it came down to the browser then closed, but it would be better if the server sent the PDF and didn't send the page. Any advice would be much appreciated.

« previous php.general (#299695) next »