How do i ensure page is in frame

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
man_with_hat
Forum Newbie
Posts: 3
Joined: Wed Feb 18, 2004 2:34 am

How do i ensure page is in frame

Post by man_with_hat »

Hi gurus..etal
this is the javascript code i use to ensure that my page is in the correct frame

Code: Select all

<script type="text/javascript">
//get a string so we can use it's search method
var str = new String(top.location);
//look for str in str
//if top location == this framed page
if(str.search('<?=$PHP_SELF?>') > -1) &#123;
  //this is not within a frame so redirect this window to the top frame
  top.location="http://www.mydomain.com/myfolder/mypage.php";
&#125;
</script>
i wanna do this in php
without using header function
any idea's?
ta
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Hello, please take the time to read this tutorial: Frames, JavaScript, and PHP Overview. Thanks,
Scorphus.
Post Reply