Question

I have a site which works within a iframe, i want it to breakout the iframe, and redirect to another site, the whole new site with its own url should open, not maintaining the current URL or iframe.

I have tried

<meta http-equiv="refresh" content="0"; URL="http://www.newsite.com/newurl.html">
and
header ('Location:http://www.newsite.com/');

they didnt work out for me.

Was it helpful?

Solution

Try this:

<script type="text/javascript">
    if (top.location!= self.location) {
       top.location = 'http://www.newsite.com/';
    }
</script>

If this runs within an iframe it will redirect the parent window to http://www.newsite.com/ .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top