-1

I am writing some code inside a portal. I have searched high and low for 2 days now with no luck. The portal that I am writing the code in, uses iframes, and it is the top most frame. When an "app" is clicked, from the portal, it displays my program. Without telling a long story, I have to also use an iframe. My page displays this iframe to take a credit card, and it listens for the response of approved or declined. I also pass the return url to the code in the iframe. Consequently, when the transaction is complete, I am redirected to the url that I passed....but it is in the iframe on my page. I know that I can use this:

<script language="JavaScript" type="text/javascript">
  function breakout_of_frame()
  {
    if (top.location != location)
    {
      top.location.href = document.location.href;
    }
  }
</script>

However that code breaks out to the top most frame, taking me out of the portal. I need to break out of the frame to the parent, and not the top. I have tried changing this code using parent, and it does not work. I have also used target="_parent" and that also does not work for my situation. (because I'm not submitting a form, I'm just sending a return url) Any help would be appreciated.

txhornsfan
  • 9
  • 1
  • 1
  • 2
  • Isn't the simple answer to not open the credit card data in an iframe? When it's complete it will just *"redirected to the url that I passed"* also I would not put credit card info into an iframe....that just screams security risk... – Liam Jul 22 '15 at 13:48
  • This is only used internally from within the portal – txhornsfan Jul 22 '15 at 13:59
  • You can't affect how the code in the iframe work's, **it's not your code**. So you either ask the people who do the code in the iframe to burst it out for you (i doubt they'll do that if it's payment processing) or use it like it's supposed to be used, i.e. don't use an iframe (what I said in the first comment) – Liam Jul 22 '15 at 14:16

1 Answers1

-1

This is probably answered here How to access parent Iframe from javascript

Long story short, use

parent.document.location

Hope this is useful!

Community
  • 1
  • 1
Igniz
  • 194
  • 1
  • 5
  • Using '' does nothing. – txhornsfan Jul 22 '15 at 14:07
  • He can't access the parent, the code in the iframe isn't his. – Liam Jul 22 '15 at 14:14
  • If I understood txhornsfan explanation right, your code is inside an iframe, and you have another iframe for the credit card info. What you need to do is pass an url from the credit card info iframe to you app iframe, is this right? – Igniz Jul 22 '15 at 14:21
  • No, he opens the credit card page in an iframe (passing it a redirect) he want's the iframe code to re-direct the parent page, not the iframe. But that's not his code, so he can't... *My page displays this iframe to take a credit card, and it listens for the response of approved or declined. I also pass the return url to the code in the iframe.* – Liam Jul 22 '15 at 14:23