Redirect page using javascript
<p>I have question,I want to redirect page using javascript which the code is to detect country id.After I looking it on google,I found a way to do it.</p>

<p>on the html in <code>&lt;head&gt;</code>tag,I insert the window.location = language,language is variable that will detect country id from geoapi_country_code
here's the code.</p>

<pre><code>var language = geoapi_country_code();
</code></pre>

<p>here's the problem,when I use the variable in the window.location,it doesn't work but if I put normal string it works.
my question,is my way to redirect is correct or there's another way to do it?please explain it to me thanks in advance</p>

<p>I have tried with window.location.href and it works but now here comes another problem,after the web redirect,it's not stopping but redirect again and again how do I stop that?</p>

<pre><code>&lt;script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
    var language = geoip_country_code();
    if(language == "ID")
    {
        window.location.href= "&lt;?php echo $this-&gt;rootUrl(); ?&gt;" + '/' + language.toLowerCase() ;
    }
    else
    {
        window.location.href = "http://localhost/lamanbudaya/public/en";
    }
&lt;/script&gt;
</code></pre>
