Jump to content

Recommended Posts

Hi

 

In some situations, I use the following example to get the current url of the page I am working on.

 

<?

$thisPage = $_SERVER['REQUEST_URI'];

if ($thisPage == "/") {echo $thisPage; }

?>

 

If I have a php page in an iframe on a none php page, is there any way I can get the URI of the containing page from my script within the iframe?

 

Many Thanks

 

MisterM

 

 

Link to comment
https://forums.phpfreaks.com/topic/160469-how-to-get-url-of-parent-frame/
Share on other sites

Hi

 

Thanks for the reply.

 

I tried your suggestion but it didn't come up with anything I could use.

 

Thanks again

 

Mr M

 

 

No. Well, it might be in HTTP_REFERER, but I'm not sure. I suppose you can check that out. You shouldn't rely on that though.

I actually just ran into this same issue yesterday.

 

From what I'm reading no PHP variables will be able to return the parent frame URL but you should be able to use javascript such as window.parent.location.href

 

I ended up just sending the data I needed to the iframe as a GET variable and then used that in the iframe page as $url = $_GET;

 

Hope that helps.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.