Disable Direct Access to iframe !

Hey today i'm gonna show you how to NOT let people access your iframe directly !

It's quiet simple in JavaScript ;)

here is the code: (make sure you put it above the </head> tag)

<script type="text/javascript">
    if (top.location == self.location) {
        top.location = "FULL-URL-HERE";
Just make sure you replace the "FULL-URL-HERE" to the URL you would like to redirect them ;)

And you'r done no one can access your iframe directly :)

1 comment:

  1. It's not great solution as you are doing it on client side. Simple turned off js can access your iframe.