Prevent iframe from redirecting parent page

This is the situation: I have the same iframe domain inside my website. I currently do not have immediate access to the iframe code as deployment problems arise.

when an iframe loads, the code inside it detects what causes a redirect to the parent page. Temporarily, I want to delete it. I know that I can use onbeforeload, but a warning will be displayed every time the user clicks on any link.

Is there a way to detect redirection? this happens before the main parent page is fully loaded.

I worked a lot at Google, but I did not have a working solution.

Thank!

+5
source share
4 answers
+5

:

<iframe align="left" src="http://stackoverflow.com/" sandbox=""></iframe>'
+2

onbeforeunload, .

<script>
    window.onbeforeunload = function(){
        return false; // This will stop the redirecting.
    }
</script>  

Stackoverflow!!!

0

It's a bit ugly to hack, but here is something that might work (I admit I don't know much about faking iframes). Take the page you want to put in the iframe via javascript. Use javascript to parse it until you go to the redirect code and separate the redirect code. Then put the result in an iframe. Awful at best, but it looks like it might work.

-3
source

All Articles