0
   

Javascript language detection :: language based redirection

 
 
Reply Wed 30 Jul, 2003 01:56 am
This javascript is used to detect a visitor's language in his/her browser and redirect to the page of your choice. It also has a default page.

Language abbreviations for browsers

Here is the script:

Code:<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (navigator.appName == 'Netscape')
var language = navigator.language;
else
var language = navigator.browserLanguage;
if (language.indexOf('en') > -1) document.location.href = 'english.html';
else if (language.indexOf('de') > -1) document.location.href = 'german.html';
else if (language.indexOf('it') > -1) document.location.href = 'italian.html';
else
document.location.href = 'defaultpage.html';
// End -->
</script>
 
  2  
Reply Wed 30 Jul, 2003 02:01 am
If you have any questions, need help or want a PHP language redirection script let me know.
  1  
Reply Mon 20 Jul, 2009 10:05 am
How i have to do, if want to put the detection for all browsers?

Do i have to copy paste all the script and each time change the name of the browser or i have to specify all the browsers on the general script?

Thank you, waiting the answer.
  2  
Reply Mon 20 Jul, 2009 12:38 pm
I'm not sure what you are asking.

If the script doesn't work across browsers that may be due to different JavaScript implementations, and it may not be possible to read local language settings with JavaScript in some browsers.
  1  
Reply Tue 21 Jul, 2009 07:17 am
So you want to say, that this script, as it is, should work for every browser?

Because the place that it says "Netscape" i thought i need to change that by, example, FF or IE.
  2  
Reply Tue 21 Jul, 2009 09:46 am
It probably doesn't work in every browser. But that Netscape code doesn't mean it only works for Netscape. Give it a try and see if it works.
  1  
Reply Tue 21 Jul, 2009 02:46 pm
I got it, thanks dude, this will be a good solution then, cause the company i work for don't want to use PHP, they use ASP, and this sucks, the problem is that i'm good programming in Asp.net, i can read, but not code.
0 Replies
 
 

Related Topics

How does one uninstall a program? - Question by Woollcott
Digital Countdown script. - Discussion by asechka
Cool Effects - Discussion by Twistmaster9000
JavaScript debugger needed. - Discussion by chevalier
 
  1. able2know
  2. » Javascript language detection :: language based redirection
Copyright © 2009 Horizontal Verticals :: Page generated in 0.36 seconds on 11/22/2009 at 12:05:38 Top End