Redirect working just outside iframe

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fershira
Forum Newbie
Posts: 2
Joined: Mon Jul 19, 2010 6:50 am

Redirect working just outside iframe

Post 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!
Bind
Forum Contributor
Posts: 102
Joined: Wed Feb 03, 2010 1:22 am

Re: Redirect working just outside iframe

Post 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>
fershira
Forum Newbie
Posts: 2
Joined: Mon Jul 19, 2010 6:50 am

Re: Redirect working just outside iframe

Post by fershira »

Thanks! It worked perfectly! cool... a simple JS!
Post Reply