I have the following problem under Internet Explorer only:
1. User fills out form data (myform.php) and clicks a button that fires
myFunction()
2. myFunction() spawns a "hello, world" popup page via window.open
3. myFunction() submits the main page's form via document.form.submit()
5. User closes popup window and clicks browser's Back button to return
to form entry page
6. All the form data that the user had filled out is now blank (back to
defaults)!
If you take step 2) out of the equation, then the form data that the
user submitted is still there in step 6). This is the behavior I want,
and I am mystified as to why the addition of window.open causes a
difference under IE. What could be going on here? If it were a
cache-related issue, I wouldn't expect step 2) to have any bearing on
the situation.
Below is a single PHP file you can save to see the problem for
yourself. As an aside, the same thing happens if you write the
equivalent logic in perl, but in a straight HTML/javascript version,
there is no problem.
Thanks for any pointers,
John
----------
<html>
<title>PHP Version</title>
<body>
<?php
if ($_REQUEST['Phase'] == 'Summary')
{
?>
<p><b>Form Submitted</b></p>
<p>This is the post-submit version of the form...</p>
<?php
}
else
{
?>
<script language="javascript">
function submitForm()
{
if (document.form1.popup[0].checked)
{
var popup = window.open('', 'popup', 'width=200,height=200')
popup.document.write('<html><body><p><b>PHP version:</b><br>Close
me, then use browser Back button and notice that your form fields are
empty!</p></body></html>');
}
document.form1.submit();
}
</script>
<p>This is the pre-submit version of the form...</p>
<form name="form1" action="" method="get">
Text 1: <input type="text" size="12" name="text1"><br>
<input type="radio" name="popup" value="show"> Open Popup
Window<br>
<input type="radio" name="popup" value="noshow" CHECKED> No
Popup<br>
<input type="button" name="Submit" value="Submit"
onclick="submitForm();">
<input type="hidden" name="Phase" value="Summary">
</form>
<?php
}
?>
</body>
</html> 4 8133
On Tue, 2006-03-21 at 11:40 -0800, jw***@alum.mit.edu wrote: I have the following problem under Internet Explorer only:
1. User fills out form data (myform.php) and clicks a button that fires myFunction() 2. myFunction() spawns a "hello, world" popup page via window.open 3. myFunction() submits the main page's form via document.form.submit() 5. User closes popup window and clicks browser's Back button to return to form entry page 6. All the form data that the user had filled out is now blank (back to defaults)!
If you take step 2) out of the equation, then the form data that the user submitted is still there in step 6). This is the behavior I want, and I am mystified as to why the addition of window.open causes a difference under IE. What could be going on here? If it were a cache-related issue, I wouldn't expect step 2) to have any bearing on the situation.
Below is a single PHP file you can save to see the problem for yourself. As an aside, the same thing happens if you write the equivalent logic in perl, but in a straight HTML/javascript version, there is no problem.
Thanks for any pointers, John
----------
<html> <title>PHP Version</title> <body> <?php if ($_REQUEST['Phase'] == 'Summary') { ?> <p><b>Form Submitted</b></p> <p>This is the post-submit version of the form...</p> <?php } else { ?> <script language="javascript"> function submitForm() { if (document.form1.popup[0].checked) { var popup = window.open('', 'popup', 'width=200,height=200') popup.document.write('<html><body><p><b>PHP version:</b><br>Close me, then use browser Back button and notice that your form fields are empty!</p></body></html>'); } document.form1.submit(); } </script> <p>This is the pre-submit version of the form...</p> <form name="form1" action="" method="get"> Text 1: <input type="text" size="12" name="text1"><br> <input type="radio" name="popup" value="show"> Open Popup Window<br> <input type="radio" name="popup" value="noshow" CHECKED> No Popup<br> <input type="button" name="Submit" value="Submit" onclick="submitForm();"> <input type="hidden" name="Phase" value="Summary"> </form> <?php } ?> </body> </html>
I would categorize this as a browser issue, rather than a PHP problem.
Nonetheless, a possible workaround may be to save the submitted form
data in session variables, and refill the form using the session data.
You should still prevent caching of the original page for this to work,
however. Microsoft recommends using the Expires header (header('Expires:
-1'); or <META HTTP-EQUIV="Expires" CONTENT="-1">). http://support.microsoft.com/kb/q234067/
I agree that it's most generally a browser/CGI implementation issue,
but I was hoping some fellow PHP travellers had encountered the issue
or could shed some light on why it happens in my simple example.
(That's assuming others can readily reproduce the behavior, which may
not be the case if server settings are the culprit here.)
It's true that I can get around the problem with additional code
overhead. However, I'm hoping for pointers about why this happens at
all, whether it's actually expected behavior, and how caching/HTTP
header info could be coming into play here when the behavior seems to
be controlled by DOM-related activity alone (window.open).
Thanks for the ideas--hoping for others as well,
John jw***@alum.mit.edu wrote: I have the following problem under Internet Explorer only:
1. User fills out form data (myform.php) and clicks a button that fires myFunction() 2. myFunction() spawns a "hello, world" popup page via window.open 3. myFunction() submits the main page's form via document.form.submit() 5. User closes popup window and clicks browser's Back button to return to form entry page 6. All the form data that the user had filled out is now blank (back to defaults)!
<snip>
<news:11**********************@z14g2000cwz.googleg roups.com> ( http://groups.google.com/group/comp....9f341b6ab55630
)
--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/
Good info, though it doesn't seem to shed any light on why Internet
Explorer seems to exhibit different caching behavior depending on
whether or not a window was spawned via window.open prior to form
submission.
I am not using sessions at the PHP level and would rather not introduce
that across my code base just for this, so the session-related material
probably isn't an answer for me.
The solution I am going to pursue is to manually write out a
"Last-Modified" HTTP header with the last-modified time of the script
itself. This definitely works around the apparent IE bug that I
described above, but it may cause me other grief that I haven't
discovered yet.
Thanks for all the advice,
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eric |
last post by:
Hey Everyone..
I have a form that has approximately 7 text fields and 1 checkbox.
Generally when this form is submitted(to itself BTW) it works fine,
however, when the checkbox is only field...
|
by: Tom |
last post by:
I have created the following code for a product select/payment form (don't know if there is a better
way) and I have been trying to make the following changes (unsuccessfully so far):
1) ...
|
by: Eli |
last post by:
How can I POST a form into a new window where I control the size and
other attributes of the new window?
Also. Are there any implications, perhaps due to browser security
(Interne Explorer?)...
|
by: Billy Boone |
last post by:
I have a web form that allows the user to enter several pieces of
information. They can then click to see the results (which takes them to a
report form). From this form, if the user clicks the...
|
by: Philippe C. Martin |
last post by:
Hi,
I am trying to change the data in a form field from python. The following
code does not crash but has no effect as if "form" is just a copy of the
original html form.
Must I recreate the...
|
by: User |
last post by:
Form A (Main)
Text Box 1
Text Box 2
Text Box 3
Form B (Pop-up)
Choose a selection for Form A/Text Box 3
Scenario:
|
by: ak1dnar |
last post by:
Hi, I got this scripts from this URL
There is Error when i submit the form.
Line: 54
Error: 'document.getElementbyID(....)' is null or not an object
What is this error.
Complete Files
|
by: Fester Bestertester |
last post by:
Greetings,
I'm an occasional php/mysql dabbler.
I have a basic data form with a submit button. Unfortunately, it's still
possible for the user to enter data changes and close the window,...
|
by: V S Rawat |
last post by:
using Javascript, I am opening a web-based url in a popup window.
MyWin1=Window.Open(url, "mywindow")
There is a form (form1) in the url in that popup window, I need to
submit that form.
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| | |