1

I have a web application where we've embedded a payment form in an iframe (or the iframe is loaded by a script provided by the payment gateway). The problem is that at one point, the page loaded in the iframe tells the top window to redirect to a new url. We want that redirect to take place within the iframe itself. We could add some sandbox-parameters to the iframe, but then it wouldn't work at all instead (the redirect just doesn't happen then).

Is there a way to get the url that the iframe is trying to navigate to? Then we could prevent it from changing the top frame, and show it in the iframe instead.

Anton Gildebrand
  • 3,641
  • 12
  • 50
  • 86
  • possible duplicate of [How to prevent IFRAME from redirecting top-level window](http://stackoverflow.com/questions/369498/how-to-prevent-iframe-from-redirecting-top-level-window) – Marcos Pérez Gude Sep 16 '15 at 15:06

1 Answers1

0

You can't modify the javascript and all contents of a frame/iframe in another domain, due security reasons. So the owner of the payment gateway should change this behaviour. If they had this behaviour it's because he wants to prevent that you have the payment gateway in a frameset or iframe, so mandatory are they. Sorry :(

Marcos Pérez Gude
  • 21,869
  • 4
  • 38
  • 69
  • Yes I know that I can't change the iframe content. But my question was rather if it's possible for the parent window of the iframe to detect (and prevent) the iframe trying to make the top frame redirect. – Anton Gildebrand Sep 16 '15 at 15:01
  • I've found a duplicate in stackoverflow: http://stackoverflow.com/questions/369498/how-to-prevent-iframe-from-redirecting-top-level-window . I don't trust so much this topic, but maybe it works for you. Good luck! – Marcos Pérez Gude Sep 16 '15 at 15:06