Return to Snippet

Revision: 51417
at August 22, 2012 00:31 by brownrl


Updated Code
function getUrlVars()
{
  var vars = {};
  var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
  });
  return vars;
}

Revision: 51416
at September 23, 2011 17:33 by brownrl


Initial Code
function getArgs()
{
    var args = new Object();
    var query = location.search.substring(1); 
    var pairs = query.split("&"); 
    for(var i = 0; i < pairs.length; i++)
    {
        var pos = pairs[i].indexOf('='); 
        if (pos == -1) continue; 
        var argname = pairs[i].substring(0,pos); 
        var value = pairs[i].substring(pos+1);
        args[argname] = unescape(value); 
    }
    return args; 
}

Initial URL
http://www.itsgotto.be/cv.php

Initial Description
This will get the arguments on the query string and put them into a handy array.

Initial Title
Get Query String Args  Javascript

Initial Tags
browser, query

Initial Language
JavaScript