View Full Version : Multiple Redirecting webpages
dean80
10-22-2002, 06:43 PM
Hello All.
I have a question regarding multiple redirects residing in the same page. Right now I have webpages setup to redirect each link to an external site as needed, but is there a way to create a single page that redirects multiple links that correspond with a website?
As an example, think of yahoo.com. Yahoo has many different directories and currently if I wanted to make redirects for the personals, news, and games sections I'd need 3 redirecting pages. Is there a way that I can create a single Yahoo page and depending on the link the user follows, it can properly redirect them based on their choice?
Looking forward to your suggestions, and thanks in advance!
Dean
ShriekForth
10-22-2002, 07:04 PM
There are probably dozens of ways.
This is setup to work from the same page, but you could set the links up on another page. If it's not an index that is in the array it will do nothing.
<script type="text/javascript" language="JavaScript">
msgArray = new Array("", "http://www.yahoo.com", "http://www.yahoo.com/news/", "http://www.yahoo.com/sports");
function getID(){
var str = new String(document.location);
vars = str.split("=");
if ((vars[1] > -1) && (vars[1] < msgArray.length)){
return vars[1];
}
else{
return 0;
}
}
function goToURL(url){
if (url!=0){
window.open(msgArray[url],'WinName','');
}
}
</script>
<body onLoad="goToURL(getID())">
<a href="redir.html?url=1">yahoo.com</a><br>
<a href="redir.html?url=2">yahoo.com/news</a><br>
<a href="redir.html?url=3">yahoo.com/sport</a><br>
Is this what you meant?
ShriekForth
dean80
10-22-2002, 09:21 PM
Hi Shriek. Thanks for the speedy suggestion! This is sorta what I was going for. What ideally I'd like to be able to do is when the user clicks a link, a new window is created and the resulting webpage can determine which link out of the group is going to redirect. Instead of having a listing of links like you have, I just need it to figure out which was picked and display ONLY that one specifically.
Make sense? Thanks again for your help!
ShriekForth
10-22-2002, 10:31 PM
You could just pass the link along instead of the index as I have it there. But at that point you may as well change the target of the actual link on the page. Unless you are tracking something, but that is up to you.
<script type="text/javascript" language="JavaScript">
function goToURL(){
var str = new String(document.location);
vars = str.split("=");
if (vars[1] != ""){
window.open(vars[1],'WinName','');
}
}
</script>
<body onLoad="goToURL()">
<a href="redir.html?url=http://www.yahoo.com">yahoo.com</a><br>
That is simpler, and the redir page would not need to know anything about the urls.
ShriekForth
dean80
10-28-2002, 06:15 PM
Thanks for the reply, and I apologize for not contacting you back sooner. I will be tracking the redir pages and that's the reason I want to have a specific window and webpage created. That way I can track exactly who's leaving my site and where they're going to.
Are you thinking that maybe have an index of links is the best way to go for this? Thanks for all your help so far. I really appreciate it alot.
ShriekForth
10-28-2002, 06:42 PM
It will probably be best just to pass the url along to the redirect page, have it store the page and the user information you are looking for like the second example. especially if there are many external links. This can make be difficult to keep track of. If they were all in an index, multiple links could be updated with one edit.
You do know the user can get away from your site in other ways correct? Opening a bookmark, tpying in a url, or a link from other app will all let the user out navigate away and you won't be able to track where to. If you are just trying to keep track of links from your site to someone elses site it will work though.
ShriekForth
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.