views:

533

answers:

2

Is there a way to break out of a frame using PHP? I have done it with JavaScript, but I would really prefer to use PHP instead. Thank you.

+6  A: 

Frames are a client-side issue. Javascript is the solution, because it is a client-side scripting language that has awareness of the browsing context. Frames are meaningless on the server-side.

So, only client-side code can do this. Not PHP.

bigmattyh
Thanks. Wasn't really sure. Just wanted to see if there was a way to do it without using JavaScript just incase there's the slim chance a user has JavaScript disabled. Thanks.
Nate Shoffner
+1  A: 

PHP is server-side. It merely generates the HTML for a page. As such there is no way for it to determine whether its output is being shown in a frame.

The best PHP can do for you is outputting the Javascript code to break out of a frame.

MathieuK