简体   繁体   中英

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

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

If it only redirects on successful attempts and not every time, then it is most likely redirected from the server (eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM