views:

417

answers:

5

Is there any way instead of a JS hack where I can post from an iframe to another page outside the iframe?

the iframe is posting data to a 3rd party and then just responding back with a URL which is the redirection URl thus we cannot set the form target. We are PCI compliant and thus we cannot use window.parent.location = url;

A: 

<form> accepts a target parameter, e.g. target="_parent"

Greg
the iframe is posting data to a 3rd party and then just responding back with a URL which is the redirection URl thus we cannot set the form target.
Murtaza RC
How do you mean "responding back"... it gives a 301 or 302, or actually returns the URL as JSON / XML / something else?
Greg
A: 

In an anchor tag you can set target='_parent' this will cause the url to be loaded into the parent window.

tpower
the iframe is posting data to a 3rd party and then just responding back with a URL which is the redirection URl thus we cannot set the target.
Murtaza RC
A: 

Do you really need to POST

Adrian
yes - since a parent.location is just like calling an entirely new URL in the browser.
Murtaza RC
A: 

No, the only way is by using javascript. But it's not really a hack to use window.parent.location = url;

tpower
We are PCI compliant and thus we cannot use that.
Murtaza RC
+1  A: 

What it boils down to, it seems, is this:
1. You get a text url from a 3rd party in the iframe.
2. You want to change your page's location to that url.
3. Unless you have control over that 3rd party, all you are going to get is that text url.

Now, the only way to change your page's location automatically is with window.parent.location (or window.location.)

If changing the url of the page with javascript is not PCI compliant then you're trying to do something that is not PCI complicant.

MDCore