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.

Était-ce utile?

La 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/ .

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top