title: JavaScript redirect users based on browser language (Chrome Extension)
body: <p>I'm trying to show different tab on chrome extension using JavaScript, but it's not working.</p>
  
  <p>In this case, it redirects only to <code>it.example.com</code> and when I change my browser language to English or French, thats script redirects only to <code>it.example.com</code>.</p>
  
  <p>Can someone show me how I can redirect based on the browser language?</p>
  
  <p><strong>I want to do different redirections for <code>it</code> and <code>fr</code>. Other languages should be redirected to English.</strong></p>
  
  <p>newtab.html</p>
  
  <pre><code>&lt;head&gt;
      &lt;title&gt;Loading...&lt;/title&gt;
      &lt;script type="text/javascript" src="js/newtab.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>newtab.js</p>
  
  <pre><code>if (window.navigator.language === 'it') { 
  window.location.href = 'https://it.example.com/';
  }
  
  if (window.navigator.language === 'fr') { 
  window.location.href = 'https://fr.example.com/';
  } 
  
  else window.location.href = 'https://example.com/';
  </code></pre>