-1

I have an url like below http://www.grcparfum.it/home.php?section=letteradelpresidente&lang=eng

in this URL language is english

lang=eng

i wanna call different JS file when lang is different

  • This question has [90 answers](http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/901119#901119) already. – Teemu Jul 13 '15 at 16:06

1 Answers1

0

Here's a function that can get the querystring variables in JS for you:

function $_GET(q){
    var $_GET = {};
    if(document.location.toString().indexOf('?') !== -1){
        var query = document.location
                       .toString()
                       .replace(/^.*?\?/, '')//Get the query string
                       .replace(/#.*$/, '')//and remove any existing hash string
                       .split('&');
        for(var i=0, l=query.length; i<l; i++){
           var aux = decodeURIComponent(query[i]).split('=');
           $_GET[aux[0]] = aux[1];
        }
    }
    return $_GET[q];
}

Does this help at all?

neilsimp1
  • 1,242
  • 1
  • 11
  • 25