[prog] JavaScript question: submitting a form to a new Window in IE 5.5

Almut Behrens almut-behrens at gmx.net
Fri Oct 7 14:05:23 EST 2005


On Fri, Oct 07, 2005 at 10:35:13AM +1000, Mary wrote:
> On Fri, Oct 07, 2005, Mary wrote:
> > I will double check at work today, but I think we've tried this already,
> > and... it doesn't work. It exhibits the same behaviour as described
> > previously. It works on IE 6, but so does my original example. They seem
> > to have pretty different behaviour for this kind of problem.
> 
> Neither of the following work on IE 5.5:
> (...)
> Both of these have the same behaviour as that described in my initial
> mail. (Note that all three variations work on IE 6.)

Interestingly, my version of IE 6 actually did exhibit the problematic
behaviour you described (with your original code).  Apparently, IE 6 is
not IE 6 -- well, not too surprising, after all...

Before we give up... could you run the following test page in IE 5.5,
and report back what you get.  This might help to confirm or generate
further hypotheses.

<html>
<head>
  <script type="text/javascript">
  <!--
  function submit_confirmed(msg) {
    window.open('javascript: alert("'+msg+'")', 'foo', 'width=450,height=300,status=yes');
    document.myform.submit();
  }
  function submit_delayed(ms) {
    window.open('', 'foo', 'width=450,height=300,status=yes');
    setTimeout('document.myform.submit()', ms);
  }
  // -->
  </script>
</head>

<body>

<form name="myform" action="" target="foo">
<input name="q">
<p><button type="button" onclick="window.open('', 'foo', 'width=450,height=300,status=yes');">
   1: create new window 'foo'
   </button>
<p><button type="button" onclick="document.myform.submit();">
   2: submit into existing window 'foo'
   </button>
<p><button type="button" onclick="submit_confirmed('Click OK to continue')">
   3: open window and confirm to submit
   </button>
<p><button type="button" onclick="submit_delayed(3000)">
   4: open window and auto-submit after delay
   </button>
</form>

</body>
</html>

You should see 4 buttons.  As a first test, press button 1, then - when
the window is open - button 2.
Button 1 should just open the small window 'foo' (no submit).
Button 2 should then submit into this new window (via target='foo').

This _has_ to work. If it doesn't, the browser is plain broken
("target=..." doesn't work at all).  In this case you're basically out
of luck.  Call Microsoft support and tell them to fix it ;((
<sarcasm> Having support always is the argument making people choose
proprietary software over free software, isn't it?  So, ... </sarcasm>

If this works, the problem with the attempts so far might be that the
window.open() returns prematurely, i.e. before the window is fully
usable.  In this case, executing submit immediately afterwards might
still not find its target 'foo' (as intended), and thus open another
window...

Pressing buttons 3 and 4 might help to shed some light on this
hypothesis (of course, close the new window every time before pressing
those buttons).
Button 3 should present a little alert box. Nothing else should happen
before the dialog is confirmed (at least not the submit -- the new
window might perhaps already be visible).  Upon confirming the dialog,
the submit is expected to execute.
Button 4 tests a similar scenario, except that here the submit is
automatically executing after a delay of 3 seconds (should be more than
sufficient to get the window in a working state...).

Haven't yet tested this myself with any IE... but well, let's just see
what you find.

Almut

(BTW, I'll be away (without access to a computer) from now until Sunday
evening.)



More information about the Programming mailing list