PDA

View Full Version : Get URL of Previous Page


Candrias77
01-06-2003, 01:55 AM
When one of my pages links to an external URL I have it opening in a new window. This new window is a frameset with a menu in a small top frame so that users can get back to my site.

I always link to the same frameset page (link.php) - the lower, main frame URL is defined when the page is linked to, ie. I would open the external link with the code below:

<a href="link.php?link=http://www.apple.com" target="_blank">

The small, top frame is always the same and contains the "back to where you came from" link.

A simple java history-1 link will not work because the visitor may have clicked on links within the lower frameset - it needs to get the url of the refering page.

Hope that this post makes sense, I appreciate any help.

ez4me2c3d
01-06-2003, 04:01 AM
in the top frame wher eyou have the link to go back, you can simply code in the page they clicked from...

<a href="link.php?link=http://www.apple.com&prev=http://yourdomain/thepage.ext" target="_blank">

i believe php can pull the current file's name for you, so getting the prev value shouldn't be too hard

Ökii
01-06-2003, 10:19 AM
$_SERVER['REQUEST_URI'] should return the current url/uri

sir pannels
01-06-2003, 10:38 AM
and theres $HTTP_REFERER :thumbsup:

Candrias77
01-06-2003, 08:10 PM
Thanks guys, I ended up using passing the previous page's url to the top frame by puting this code in the frameset:

<frame src="linkNavigation.php?prev=<? echo $HTTP_REFERER; ?>".....>

Then just used <? echo $prev; ?> in the actual frame.

Works perfectly for all pages that link to it, thanks guys.