PDA

View Full Version : Browser redirection by language


Bob
04-19-2003, 12:35 PM
Anyone know of any tiny scripts that will redirect a user to the correct page based on the language of their browser? I have tried four different ones now and all seem to have glitches or didn't work at all. Just something simple like this: (It doesn't work the way it is for some unknown reason.)

<script language="JavaScript1.2">
<!-- Begin
if (navigator.appName == 'Netscape')
var language = navigator.language;
else
var language = navigator.browserLanguage;

if (language.indexOf('en') > -1) document.location.href = 'index.htm';
else if (language.indexOf('ja') > -1) document.location.href = 'http://www.editfast.com/japanese/index.htm';
else
document.location.href = 'http://www.editfast.com/index.htm';
// End -->
</script>

Dudex
04-20-2003, 01:29 AM
You might want to stick with the old tried and true method, asking the user where they live.