Click to See Complete Forum and Search --> : Redirecting Page


Traffic
03-11-2003, 03:54 PM
hello...

I have put together an HTML page that will capture environmental information, save it and then forward the end user to another page...

Everything works great... except... for some reason I can't get the forwarding the other user to the next page to work...

==========================================

<html>
<head>
</head>
<body>

<script language="javascript" type="text/javascript">

querystring = window.location.search;
querystring = querystring.split("&");
part1 = querystring[0];
part1 = part1.split("=")
part2 = querystring[1];
part2 = part2.split("=");
part3 = querystring[2];
part3 = part3.split("=");
document.write ("Table is "+part1[1]);
document.write ("<br>");
document.write ("CUID is "+part2[1]);
document.write ("<br>");
document.write ("URL is "+part3[1]);

</script>

<script language="javascript"><!--
srb="na";srw="na";an=navigator.appName;d=document; s=screen;srw=s.width;srh=s.height;an!="Netscape"?srb=s.colorDepth:srb=s.pixelDepth;sc=Math.pow(2, srb);
pr();function pr(){ d.write("<img src='http://selectrak.com/cgi-bin/trak.pl?tag="+part2[1]+"&table="+part1[1]+"&srw="+srw+"&srh="+srh+"&sc="+sc+"&srb="+srb+"&r=TrafficGuaranteed' height=1 width=1>");} //-->

document.href=part3[1];

</script><noscript><img height=1 width=1 src="http://selectrak.com/cgi-bin/trak.pl?tag=$cuid&table=$table"></noscript>";


</body>
</html>

==========================================


document.href=part3[1];

I thought I had this correct... but, it is not working...

Thank you for any help you can give me...

khalidali63
03-11-2003, 04:06 PM
You will need to check that part3[1] has the correct URL where you want the user to be redirected.If not then re-design the URL reading part of your code.

Cheers

Khalid

Traffic
03-11-2003, 04:14 PM
It is the correct code...

I am passing a urlEncoded URL as 'part3[1]'... and I got the redirection to semi-work...

I used: window.location=part3[1];

Except...

it redirects to http://mydomain.com/test/[FULL URL GOES HERE]

So, it does not redirect the page... it just adds the URL onto the final directory where my page resides...

I fixed this by using an 'unencoded' URL... however, I need to urlencode the URL in order to pass the entire URL to the other page...

how do I unEncode the URL using javascript...?

Any suggestions...?


Thanks again...

pyro
03-11-2003, 04:16 PM
alert part3[1] and let us know what it returns...

Traffic
03-11-2003, 04:23 PM
Ok...

I did the:

alert(part3[1])

and it returned... the URLencoded URL...

this is being added onto the final folder of my URL up there already instead of being redirected to:

URL

it is being redirected to:

http://myfirsturl/folder/URL

HELP...


How do I unencode the URL before I redirect...?

Thanks again for your help...

pyro
03-11-2003, 04:27 PM
You still didn't tell me what part3[1] is returning. Give me the exact string...

Traffic
03-11-2003, 04:34 PM
Sorry...

Here it is...

http%3A%2F%2Fwhatever.com%2Fthis%2Fthat.htm%3Fname%3Dwhatever%26this%3Deverything

And it is redirecting to:

http://mydomain.com/folder/http%3A%2F%2Fwhatever.com%2Fthis%2Fthat.htm%3Fname%3Dwhatever%26this%3Deverything

instead of:

http://whatever.com/this/that.htm?name=whatever&this=everything



Thanks again for your help...

pyro
03-11-2003, 04:39 PM
Try adding this:

url = unescape (part3[1]);
window.location.href = url;

Traffic
03-11-2003, 05:24 PM
thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you


works great...

pyro
03-11-2003, 05:34 PM
Your welcome :D