Javascript to choose language does not work

wxdqz

New Member
I copied the following script to put in my website, so first time visitors would choose the language and be redirected to the homepage of that language. I need help in:

1.When the box is checked, the cookie is set correctly, the visitor is not redirected to the respective language home page.

2.How do I insert clickable GIF buttons (instead of the checkboxes) in this script?

Thanks a lot

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>ABLE International - choose your language</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ronnie T. Moore -->
<!-- Web Site: The JavaScript Source -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! <!-- m --><a class="postlink" href="http://javascript.internet.com">http://javascript.internet.com</a><!-- m --> -->

<!-- Begin
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var favorite = GetCookie('animal');

if (favorite != null) {
switch (favorite) {
case 'francais' : url = 'bienvenue.htm';
break;
case 'english' : url = 'welcome.htm';
break;
case 'portugues' : url = 'bemvindo.htm';
break;
case 'espanol' : url = 'bienvenido.htm';
break;
}
window.location.href = url;
}
// End -->
</script>
</HEAD>
<BODY bgColor=#000066>
<div align="center">
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>
<form>

<table> <tr><td><font face="verdana"><font size="5"><font color="#ffffff"><center><BR><BR><BR>
You are entering into the website of<br>ABLE International<p></font>

<font face="verdana"><font size="3"><font color="#ffffff"><center>Please select your language.<br>
You will need to do this selection only one time. <br>
Making a selection will place a 'Cookie' in your computer.<br>If you have cookies disabled in your browser, it will not work.<br>
<p></center>

<input type=checkbox name="francais" onClick="SetCookie('animal', this.name, exp);">fran鏰is
<input type=checkbox name="english" onClick="SetCookie('animal', this.name, exp);">english
<input type=checkbox name="portugues" onClick="SetCookie('animal', this.name, exp);">portugu阺
<input type=checkbox name="espanol" onClick="SetCookie('animal', this.name, exp);">espa駉l


<br>

</td></tr>
</table>
</form>
</center>
<font face="verdana"><font size="3"><font color="#ffffff"><center>If you do not wish to place a 'Cookie' in your computer,<br> click in the link below.<BR>

<center>
<font face="verdana" size="3"><font color="#ffff0"><u>www.ablexx1.com</u>
<a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.ablexx1.com/welcome"></a></font>
</center><p>
<P><P><P>



<!-- Script Size: 2.84 KB -->
</body>
</html>
 
Back
Top