Click to See Complete Forum and Search --> : Javascript / Breaking out of frames when submitting a form???


scisuk
02-18-2003, 05:09 AM
Hi everyone,

I have a form which looks like this:

<!-- ************************************************************************************* -->
<!-- This form is all that is required to submit the payment information to the VSP system -->
</P>
<FORM ACTION="submit.pl" METHOD="post" ID="form1" NAME="Test">
<INPUT TYPE="hidden" NAME="Protocol" VALUE="2.20">
<INPUT TYPE="hidden" NAME="TxType" VALUE="PAYMENT">
<INPUT TYPE="hidden" NAME="Vendor" VALUE="">
<INPUT TYPE="hidden" NAME="Crypt" VALUE="">
<INPUT TYPE="image" SRC="proceed3.gif" VALUE="Submit the Order details" ALIGN="right" >
</FORM>
<!-- ************************************************************************************* -->

Effectivley, when clicking submit, I want the result that would happen normally to open in a new window.

Can this be done?

If so can I ask even more and close the old window behind it?

Any help much appreciated.

Thanks,

Simon

Charles
02-18-2003, 05:55 AM
JavaScript cannot close a window that JavaScript did not open and if you try some browsers will throw an error and you will end submitting the form twice.. This method will check before trying to close the window:

<FORM ACTION="submit.pl" METHOD="post" ID="form1" NAME="Test" TARGET="_blank" ONSUBMIT="this.submit(); if (top.opener) top.close(); return false">

And if you want to control the geometry of the window opened:

<FORM ACTION="submit.pl" METHOD="post" ID="form1" NAME="Test" TARGET="child" ONSUBMIT="window.open('', 'child' 'height=400,width=300'); this.submit(); if (top.opener) top.close(); return false">

scisuk
02-18-2003, 06:08 AM
Thanks for the info!

Much appreciate it!

However.... The code seems to have no effect on the page.

A couple of questions:

Would it not be working because I am using an image instead of a button?

Would it not be working because it is in a Perl/CGI script?

The page is still working fine, however when I click submit, it opens in the same window and not a new one. The code is there as I have viewed the source.

Thanks again.

Simon

Charles
02-18-2003, 06:25 AM
Can you post the URL? Even if JavaScript is disabled, either example I gave will, on a graphical browser, open the form reply in a new window. Try removing the "onsubmit" handler.

scisuk
02-21-2003, 07:39 PM
Hiya,

It posts but not in a new window.

Before all of this I tried:

target="_blank"

Should that of worked? Because it didn't?

Any ideas?

I am using IE6 on Windows XP.

Thanks.

Simon

Charles
02-21-2003, 08:25 PM
If you are not going to post the URL for the page then we are not going to be able to help you.