window.open(URL, windowName[, windowFeatures]) self.close()
When ever a user enters information into the form and submits the form, the data is posted to our database and the window is closed. A trivial use of a popup window to gather information.
When you try to re-open that window, the server-side scripting should return the information. But, it does not. The original blank form is loaded and no information is retrieved from the database.
If you hit the reload button, the information is returned. But, if you change that information, the same previous information still appears until you hit the refresh button again.
Obviously, it's a cache problem and the easy fix is to add a random number to the end of the URL. But, why is this doing this? It only happens in IE9 Beta and we have no other problems in other browsers. Our concern is that we'll have to go and update all of our links throughout a very large application.
I'm sure other people have code similar to ours and will run into this situation. We're eventually turning to a full CSS based window form entry. But, that's down the road and we did not expect to run into this situation.
Using the IE9 developer tools, we changed the Browser Mode and Document Mode but no matter what we had the same problem.
Anyone have any information?
Here's some sample code for a simple test case:
<!-- Popup Calling Page --> <html> <body> <input type="button" value="Open Popup" onClick="window.open('popup.html','Test','height=300,width=400,top=0,left=0,scrollbars=yes');"/> </body> </html> <!-- Popup window Source --> <html> <body> <form action="submit.php"> Your Name <input type="text" maxlength="25" width="23"/> <input type="button" value="submit" onClick="self.close()"/> </form> </body> </html>
Please let me know if you have any suggestions on where to get an answer!
The standard design pattern for a submit button is to validate the data before the input click event is bubbled to the form submit.
<input type="button" value="submit" onClick="return false;self.close()"/>
The return false; stops the 'button' onclick event bubbling up after the form submit.
one would normall use return FormDataValid();
A ticket at connect.microsoft.com/ie has already been raised, but I beleive this is the expected behaviour, its just that other browsers return false by default.
Thanks for the update.
I'm not sure if we're talking about the same thing. I'm a bit confused. So, I went ahead and created a testing page for this exact problem.
Here's the link:
Using IE9 Beta, click the button and change the value in the window. Submit the value and then click the button again. You should see the value didn't change. If you refresh the window, you'll get the value you updated.
After that, try it in another browser and you'll see what I mean.
My submit.php script closes the window like so:
Not an actual onClick event.
Let me know what you think!