Page 1 of 1

Redirect working just outside iframe

Posted: Mon Jul 19, 2010 7:09 am
by fershira
Hello,

My problem:
When the page is called outside the iframe, I would like redirect it to another page.

Eg: The page www.something.com/A.php has an iframe <iframe src="insideA.php"></iframe>
and when insideA.php is called outside the of page A.php - www.something.com/insideA.php - it should redirect to page B.php

Solution
I believe is a simple solution... But, I am not a developer, so maybe you can help me.
Please!

Re: Redirect working just outside iframe

Posted: Mon Jul 19, 2010 8:25 am
by Bind
it's untested but should work.

Code: Select all

<script language="javascript">
<!--
if (top.location == location)
   {
       location.replace('http://your_website.com/redirect_page.php');
   }
-->
</script>

Re: Redirect working just outside iframe

Posted: Mon Jul 19, 2010 11:06 pm
by fershira
Thanks! It worked perfectly! cool... a simple JS!