Custom Global Redirect

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
tFreeman
Forum Newbie
Posts: 4
Joined: Mon Mar 15, 2004 11:05 am

Custom Global Redirect

Post by tFreeman »

Hi, I have a situation here where I have about 20 links leading to external sites, I have to make a standard page that will come up alerting visitors that the link they've click is taking them to another site. I imagine the redirect page would be good in php where the url for the "continue" button is equal to some variable set by the link that sent them to the page, but I dont know much about php and Im not sure how to go about this or maybe Im looking at the whole problem wrong, any help would be very much appreciated, thank you in advance.
tFreeman
Forum Newbie
Posts: 4
Joined: Mon Mar 15, 2004 11:05 am

Post by tFreeman »

The more I google up on this the more confused I get, every single person who has asked this question has been ignored so either there is something fundamentaly impossible about this I dont see or its something simple but either way Im completly stumped. On my redirect.htm page I tried

<a href= http://path/to/redirect.php?target=varUrl>>Variable link</a>

the contents of redirect.php was

<?php
header(location: _request['target']);
exit;
?>

I cant get varUrl to ever equal anything meaningful, I want the sending link to set that value, can I do this or am I just wasting very value time?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Here's a test that worked for me ok.

Code: Select all

<!-- redirect.html -->
<a href="/redirect.php?varUrl=http://google.com">google</a>

Code: Select all

//redirect.php
<?php
header("Location: ".$_GET['varUrl']);
exit;
?>
tFreeman
Forum Newbie
Posts: 4
Joined: Mon Mar 15, 2004 11:05 am

Post by tFreeman »

That works for me too but i need varUrl to be set by the sending link thats why I was trying to get varUrl=someOtherVar to work. Thanks for your reply
tFreeman
Forum Newbie
Posts: 4
Joined: Mon Mar 15, 2004 11:05 am

Post by tFreeman »

I finally got it with a tiny bit of hand-sewn javascript

link that leads to external site is coded like:

<a href="http://www.mySite.com/redirect.htm?xurl ... .com">link to external site</a>

then for redirect.htm I have my disclaimer page I made except I added to the head:

<script language=javascript>
function setLink(xurl){
xurl=document.location.search.substring(6);
window.open(xurl)
}
</script>

and finally made the link for the continue button

<a href="javascript:setLink();">continue</a>

this was almost too simple and works fine for those of you like me who need something simple but don't know how to ask ,I give you my mammoth creation and please send me 1200$ if you plan to use this or you could just curse me under your breath thats fine too.
Post Reply