vendredi 25 mai 2018

Detecting user language in IE

I have some code that checks the user's language. If the user is German they get sent to "de.html" otherwise they're sent to "en.html". There is also a string that checks if the user is going to the editor, ('/?edit'), and if so nothing happens. This code works fine, however, it doesn't work in IE. Any ideas?

var lang = window.navigator.language;
  var userLang = window.navigator.userLanguage;
  if (!window.location.href.includes('/?edit')) {
    if (lang == "de" || userLang == "de") {
      window.location.href = window.location.href + "de";
    } else {
      window.location.href = window.location.href + "en";
    }
  }




Aucun commentaire:

Enregistrer un commentaire