Click to See Complete Forum and Search --> : Determining if script is in a frame or _top


Bitzy
05-14-2007, 11:21 PM
I very much need a PHP script to determine if the PHP page is used in a frame or the document _top.

This page is to be used in two different worlds and a variable needs to be set if the page is in a frame and unset if used at the _top. The variable will be used to switch on or off various features of the page. If used in a frame, most features will be off.

I hope I am making myself clear. :)

It is kind of like a frame braker Javascript but switches on a variable instead of exiting the frame.

NogDog
05-14-2007, 11:31 PM
I do not believe there is any way for PHP to directly know this. You would probably need to do something in JavaScript on the client side, and perhaps use an AJAX interface to a PHP script to control the output based on the frame status.

Bitzy
05-14-2007, 11:48 PM
I do not believe there is any way for PHP to directly know this. You would probably need to do something in JavaScript on the client side, and perhaps use an AJAX interface to a PHP script to control the output based on the frame status.

I have an alternate attempt to try, but I can't figure out how to do it.

On the page that uses the frame, I can link the page and send a series of arguments, but I can't figure out how to read the passed variables.

NogDog
05-14-2007, 11:57 PM
If your link uses a query string in the following format...

<a href="page.php?var1=foo&var2=bar">Link text</a>
...then you can access the values "foo" and "bar" via the variables $_GET['var1'] and $_GET['var2'].

more info about $_GET (http://us2.php.net/manual/en/reserved.variables.php#reserved.variables.get)

Bitzy
05-15-2007, 01:20 AM
If your link uses a query string in the following format...

<a href="page.php?var1=foo&var2=bar">Link text</a>
...then you can access the values "foo" and "bar" via the variables $_GET['var1'] and $_GET['var2'].

more info about $_GET (http://us2.php.net/manual/en/reserved.variables.php#reserved.variables.get)

I very much appreciate your help, NogDog. I will give your info a try and post back here tomorrow night. Thanks so much. :)