vico
vico

Reputation: 2142

Prevent Iframe from Reloading the Parent

I have a Page with standard iframe markup

Inside the frame is Linked to a Https URL The iframe does some processing (payment info and such)

Then returns back a POST data When the processing fails most of the time it does not reload the parent(Return url, plus POST data to that URL, loads inside Iframe), and when the processing payment returns successful, most of the time it completely reloads the parent page (Returns url, plus POST data to the Successful URL, Reloads parent to that URL)

As this is code from the secure payment, there isn't alot of things I can show.

Is there any javascript or Html attr that will make this without randomness

Upvotes: 2

Views: 7760

Answers (2)

vico
vico

Reputation: 2142

End up using sandbox mode for iframe and forced stop the redirection atleast for modern browsers.

sandbox="" without allow-top-navigation will force prevent the reload

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe

Upvotes: 5

hnafar
hnafar

Reputation: 611

If it only redirects on successful attempts and not every time, then it is most likely redirected from the server (e.g. using a redirect header, or a window.refresh) then you would have to fix your code there (if you have control over it).

If you don't have control over the server side code where the iframe is coming from, ask the owner of the API for help. If they refuse (which they will most likely do) to apply the changes you need, it will probably be due to security concerns (if the user's transaction is getting processed on another server, why is the page hosted in an iframe in your page? read about click jacking)

Either way, I would use fiddler, or any other tool you can think of to examin the contents of a successful response to verify whether the server side code is redirecting.

Upvotes: 0

Related Questions