Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   Parent URL (http://www.programmingforums.org/showthread.php?t=11823)

drumltd Nov 7th, 2006 9:43 AM

Parent URL
 
I know that I can use _GET and _POST etc. to get variables that are passed to a file etc. when it's displayed. However if the php script is called from with in a frame these only return the variables passed to the frame (as expected)

Is there anyway of getting either the url or params from the top most parent window??

Cheers

Dave.

Arevos Nov 7th, 2006 9:50 AM

You could make the top parent window a PHP script, and have it forward its GET parameters to its child frames.

drumltd Nov 7th, 2006 10:40 AM

Quote:

Originally Posted by Arevos (Post 118546)
You could make the top parent window a PHP script, and have it forward its GET parameters to its child frames.

Unfortunately I don't have full control of the parent URL, (it's part of a system)

Pizentios Nov 7th, 2006 11:07 AM

you could try a javascript php combo.

a while back i had to get arrays from inside a javascript to php, i ended up doing it with some code i got off the php mailing list.

the thread can be found here: http://www.programmingforums.org/for...pt-arrays.html

you could probably pass the varibles that you want by using javascript to grab the values from the parent window. Just an idea.

drumltd Nov 7th, 2006 1:09 PM

Now you've mentioned Javascript I've had a poke around, and my idea is to have a javascript that gets the params, then adds them to the php script url and displays it, however my Javascripts isn't really upto going that. Guess it's time for a web search and start reading.

drumltd Nov 7th, 2006 2:56 PM

Well I've googled, read, and written.

I've written a little, javascript that takes a page as a parameter, and passes both it's and any parent params to it. Think it'll be fairly self how it works, cos it's the first js I've written, but just ask if anybody wants any explanations, or more likely tell me what I've done wrong.

:

<script>

stHref = top.location.href;
TopParamString = stHref.substr(stHref.indexOf("?")+1);

stHref = window.location.href;
ParamString = stHref.substr(stHref.indexOf("?")+1);

ParamArray = ParamString.split("&");
for ( var iParam = 0; iParam < ParamArray.length; iParam++ )
{
  if (ParamArray[iParam].indexOf("page=") > -1 )
    {  aValue = ParamArray[iParam].split("=");
        if (ParamString == TopParamString)
          window.location.href = aValue[1] + "?" + ParamString;
        else
          window.location.href = aValue[1] + "?" + ParamString + "&" + TopParamString;
    }
}

</script>


Hope it helps someone else.


All times are GMT -5. The time now is 1:22 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC