简体   繁体   中英

PHP redirect outside of Iframe

Greeting!

I have a webpage with a Iframe in it. The Iframe is from a third party app that the user can use. once the user finishes the application and tells the Iframe application that they are complete, they press the submit button. Once the submit button is pressed, it redirects them to a page on my site, but they still inside the Iframe.

My question is - Is there a way to force the page they are redirected to redirect the PARENT page of the Iframe? I have encountered several session/cookie issues that force the user to relog into the Iframe, thus causing a endless wave of Iframes. If I could simply simple tell Iframelanding.php to redirect its parent page to myaccount.php I would not have the compatibility issues.

Does anyone have any experience with this?

也许您可以在iframe目标网页上尝试此操作,它将重定向父iframe,但它们必须位于同一域中。

window.top.location.href = "http://www.example.com"; 

consider using this in your :

<head>
  <base target="_parent" />
</head>
<script>
$(function(){
   var isInIframe = (window.location != window.parent.location) ? true : false; 
   if(isInIframe == true){ //redirect if iframe
        window.top.location.href = "http://gmail.com/";
   }
});
</script>

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