title: Problem with document.location.href
body: <p>I am new to Javascript and Web development and I have a question regarding the document.location.href. 
  I am using a cookie for storing the language the user prefers and then load the english or the swedish version depending on the language. 
  The default language in the beginning is the same as the browser's language, and my index.jsp is the swedish one. The first time everything works fine. The problem is when the cookie exists already. The basic code is:</p>
  
  <pre><code>    if (language!=null &amp;&amp; language!=""){
          if (language=="en-US" || language=="en-us")
         document.location.href = "en/index.jsp";
       }
      else{
   //Explorer
   if (navigator.userLanguage) 
       language = navigator.userLanguage; 
  
   //other browsers
   else   
       language = (navigator.language) ? navigator.language : navigator.userLanguage;
  
   if (language!=null &amp;&amp; language!=""){
       setCookie('language', language, 365, '/', 'onCheck');
  
   if (language=="en-US" || language=="en-us")
       document.location.href = "en/index.jsp";
  
   else if(language=="sv")
       document.location.href="index.jsp";      
        }
      }
  </code></pre>
  
  <p>When the cookie exists we enter the first "if", and there, if the language is swedish it opens the default blabla/index.jsp page. When the language is set to engish it should open the blabla/en/index.jsp but instead it opens the blabla/en/en/index.jsp which of course is wrong.</p>
  
  <p>Does anyone know what I am doing wrong??
  Thanks</p>