I am using javascript top.location
to retrieve parent location through javascript
What i wanted to know is there any way to get parent 开发者_Go百科url through php?
I have tried $_SERVER
with different parameters but i am getting the child window url.
top
refers to a frame object. There is no way to distinguish a HTTP request for a document that will be rendered in a frame from one that will not.
Therefore, there's no equivalent to the client-side top.location
in php (a server-side language). You can, however, block your page from being rendered in a frame by setting the X-Frame-Options
HTTP header.
Your php server code has no chance whatsoever to know what is going on on the client. As well as your js code can't look into the server.
i used this in my php script...
if (...whatever!) { require("location_top.php"); exit; }
then in location_top.php
<?php // ?>
<h1><a href="scriptname.php" target="_top">Click here to continue</a></h1>
<script type="text/javascript">
<!--
top.location = "scriptname.php";
//-->
</script>
When the frame first loads, this should be in the HTTP Referer. See HTTP Referer on HTML Frames for details.
精彩评论