Click to See Complete Forum and Search --> : how can I manipulate the URL


blancomario
01-16-2003, 12:08 PM
I am working on a web site that provides the content on English and Spanish. I will like to have a button on each page where the user can switch between languages.

So if the English link looks like
www.someserver.com/foldera/folderb/pagea.htm

I will like to modify the link so it looks like
www.someserver.com/foldera/espanol/folderb/pagea.htm

Any ideas on how I can do this with client side javascript?

Thanks.

pyro
01-16-2003, 01:38 PM
This will work, as long as you follow very closely to the structure of only adding espanol/ into the address.

<html>
<head>
<script type="text/javascript">
function switchlanguage()
{
pageURL = top.location.href;
holder = pageURL.split("/");
filename = holder.length;
ending="";
for (i=4;i < filename; i++)
{
ending = holder[i];
}
top.location = "http://www.someserver.com/foldera/espanol/"+ending;
}
</script>

</head>
<body>
<a href="#" onClick="switchlanguage()">Switch Language</a>
</body>
</html>