Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a page.

Status
Not open for further replies.

Cheech

Technical User
Nov 6, 2000
2,933
EU
Hi
I have the following code that I post a form to with 2 submit buttons. One has the value Save and the other Print.
If the user selects the Print button the page correctly loads, the print dialogue opens & after printing the page correctly closes. However if the user selects Save, even though the correct Open/Save dialogue is triggered, the page is never fully loaded and therefore does not close.
Anyone know how this could be achieved?

Code:
<?php
    if ($_POST["submit"] == "Save") {
        header("Content-type: application/rtf");
        header("Content-Disposition: attachment; filename=MFL_free_text.rtf");
        header("Pragma: no-cache");
        header("Expires: 0");
     } 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html>
<head>
<title>Self-Evaluation</title>
<style>
body { font-family:Arial, sans-serif; font-size:10pt;}
</style>
</head>

<body onload="self.close();">
<p><a href="javascript:self.close();">Close window</a></p>
<p><strong><?php echo $_POST["client"]; ?></strong></p>
<p><strong><?php echo $_POST["title"]; ?></strong></p>
<p><?php    echo $_POST["free_text_area"]; ?></p>
<p><strong><?php echo $_POST["footer"]; ?></strong></p>
<? if ($_POST["submit"] == "Print") { ?>
<script>
self.print();
</script>
<? } ?>
</body>
</html>
Cheers

[Peace][Pipe]
 
If you remove the PHP code above the DOCTYPE, does it close as expected?

If so, you might be better off asking this in the PHP forum.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top