CancelImage Upload

How to find out what language a visitor's browser is using

If you want to get to know your website's visitors a bit better, you may want to find out what language's their browsers are in. Alternatively you may even want to adjust the language that your website is displayed in based on the browser language.

To find out a web browser's language, all that you need to do is use the following line of code. Here an example of the language being loaded into a variable:

var browserLingo = navigator.browserLanguage;

And there you have it. That is all there is to it. Below we have an extended example with the language being loaded into a span tag:

<html>
<head>
<title>How to find out what language a visitor's browser is using</title>
<script language="JavaScript">

function getBrowserLanguage()
{

          var spanLanguage = document.getElementById("language");

          spanLanguage.innerHTML = navigator.browserLanguage;

}

</script>

</head>
<body onload="javascript:getBrowserLanguage();">

<span id="language"></span>

</body>
</html>


Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com