Thread: Parent URL
View Single Post
Old Nov 7th, 2006, 2:56 PM   #6
drumltd
Newbie
 
Join Date: Aug 2005
Posts: 19
Rep Power: 0 drumltd is on a distinguished road
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.
drumltd is offline   Reply With Quote