...

View Full Version : Close Window not working



Alith7
07-16-2009, 05:45 PM
I have a basic insert form to add items to a product database. It opens as a pop-up window from a different form so that my sales reps can add items to the database if they are not there without having to back track. I want to have a close window option for when they are done.

here is what I have so far:

<body>
<div id="wrapper">
<div id="titlebar"><img src="images/header.jpg" alt="Graphic Edge Printing" /></div>
<div id="maincontent">
<div id="nav">
<?php include('navbar.php'); ?>
</div>
<h1 align="center">Sheet Size Insert </h1>
<p align="center">Check the list below, if the sheet size you would like to use is not listed, please add it. </p>
<form action="<?php echo $editFormAction; ?>" id="Press" name="Press" method="POST">
<table width="457" border="0" cellspacing="0" cellpadding="2" align="center">
<tr>
<td width="128"><div align="right">Sheet Size : </div></td>
<td width="189"><input type="text" name="SheetDesc" /></td>
<td width="128"><center><input name="Add Size" type="submit" id="Add Size" value="Add Size" />
</center></td>
</tr>
</table>

<input type="hidden" name="MM_insert" value="Press">
</form>
<p align="center">&nbsp;</p>
<table width="200" border="1" cellspacing="0" cellpadding="2" align="center">
<tr>
<th scope="col">Sheet Size Options </th>
</tr>
<?php do { ?>
<tr>
<td><div align="center"><?php echo $row_SheetSize['SheetDesc']; ?></div></td>
</tr>
<?php } while ($row_SheetSize = mysql_fetch_assoc($SheetSize)); ?>
</table>
<p>
<input name="button" type="button" onclick="window.close()" value="Close Window" />
</p>
</div>
<div id="footer"><?php include('copyright.php'); ?></div>
</div>
</body>

but the close window button doesn't work. any ideas?

Amphiluke
07-16-2009, 05:56 PM
The browser can forbid the scripts to close windows. If you are using FF, check whether the option dom.allow_scripts_to_close_windows is set to true.

Alith7
07-16-2009, 05:58 PM
Safari ATM actually.
I can check that, what if it fails though? Do have any other options?

Amphiluke
07-16-2009, 06:13 PM
Will you please post a link to your page where I can test it myself?

Alith7
07-16-2009, 06:17 PM
http://graphicedgeprinting.com/test.php

I removed the database access for security reasons.

Alith7
07-16-2009, 06:18 PM
well flip!
now it works! but after I submit a record, it doesn't.
is there any reason running the insert record function then reloading the page would make the close window button not work?

Amphiluke
07-16-2009, 06:35 PM
Most probably, when you are reloading the entire page, the popup window loses its association with an opener window and becomes an individual window, which does not treat the close() method.

Alith7
07-16-2009, 06:41 PM
That makes sense.
is there a way around that?

Amphiluke
07-16-2009, 07:29 PM
... maybe if you'll create the popup window with an iframe inside it, and you'll load the page with the form (http://graphicedgeprinting.com/test.php) into the iframe, while the 'close' button will be outside the iframe?

In the popup window (say, popup.htm)

<p><iframe id="ifrm" src="http://graphicedgeprinting.com/test.php" width="750" height="450"></iframe></p>

<!-- the button is outside the iframe -->
<p><input name="button" type="button" onclick="window.close()" value="Close Window" /></p>


In the opener window

<p><input name="button" type="button" onclick="window.open('popup.htm', '', '');" value="Open Window" /></p>

If the document is reloaded inside the iframe, it does not affect the popup window itself, so, the popup window can be closed with the "Close Window" button. Such a workaround... If it doesn't suit you, sorry, I do not see any other way.

Alith7
07-16-2009, 08:28 PM
You are right, it is not ideal, but it will work for now until I can figure out a better way to do this.

Thank you!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum