Link to home
Start Free TrialLog in
Avatar of burnsj2
burnsj2

asked on

Prevent Iframe Redirect of Parent

Some users are stealing our traffic by putting the following in an iframe, taking over the parent and then meta redirecting to another website:

<script>
if (parent.frames.length > 0) {
    parent.location.href = self.document.location
}
</script>

How can we prevent this without banning iframes?

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of burnsj2
burnsj2

ASKER

The are putting their own iframe in the free text area we provide.  Within that iframe they are src'ing to a file that has the posted code in it.  This takes over our page and then redirects it with the meta tag they also have on their page.  

I don't want to control the page on their differenet domain but rather prevent them from controlling our page.
OK. well unfortunately for you, other than contacting them and requesting to stop that practice (or else no more free space for them on your site), you cannot stop that since the content of the iframe is from an external domain.
Avatar of burnsj2

ASKER

There is one thing that works in IE only:

<iframe src="http://www.Somewhere.com/SomePage.html" security="restricted"></iframe>

security="restricted" prevents framebusting. Too bad it doesn't work in FF etc.