NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP and framesets

D C Krook dkrook at hotmail.com
Wed Aug 6 13:00:23 EDT 2003


Hans is right, PHP wouldn't know that it is in a frameset.  Only the client 
knows that, which is after the PHP is executed.

You can throw around the parent frame's PHP_SELF with something like this:

In the parent frameset declaration page:
-----------------------------------------
<script type="text/javascript">
var self = <?= $_SERVER['PHP_SELF'] ?>;
function getSelf () {
	return self;
}
</script>
<frameset rows="50,20,*">
    <frame name="top" src="top.php" marginwidth="0" marginheight="0" 
scrolling="auto" frameborder="0">
	<frame name="middle" src="middle.php" marginwidth="0" marginheight="0" 
scrolling="auto" frameborder="0">
    <frame name="bottom" src="bottom.php" marginwidth="0" marginheight="0" 
scrolling="auto" frameborder="0">
</frameset>
-----------------------------------------


And in the child, e.g., "top.php":
-----------------------------------------
	<script type="text/javascript">
	var par = window.parent;
	var self = par.getSelf();
	</script>
-----------------------------------------


>>This seems simple enough, but maybe it isn't that simple... Does anyone 
>>know
>>of a way to have PHP return the top level document's location? Basically I
>>have a script that references PHP_SELF... if you throw it into a frameset,
>>it naturally returns the frame source URL, not the frameset's.
>
>As far as I know, a frameset is a client-side thing, so PHP wouldn't know 
>anything about it natively.  You could, perhaps, have some kind of 
>Javascript callback to a php script, but I don't really know how you'd do 
>it in JS :)
>
>H

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail




More information about the talk mailing list