Return to Snippet

Revision: 28027
at February 1, 2011 01:28 by fengelz


Updated Code
function request(value) 
{
    var queryStr = location.href.split('?');
    if (queryStr.length < 2){ return ""; }
    var requestObj = {};
    var level1 = [];
    level1 = queryStr[1].split('&');
    for (var i = 0; i < level1.length; i++) {
        level2 = level1[i].split('=');
        requestObj[level2[0]] = level2[1];
    }
    return decodeURIComponent(requestObj[value]);
}

Revision: 28026
at June 29, 2010 23:03 by fengelz


Initial Code
function request(value) 
{
    var queryStr = location.href.split('?');
    if (queryStr.length < 2){ return ""; }
    var requestObj = {};
    var level1 = [];
    level1 = queryStr[1].split('&');
    for (var i = 0; i < level1.length; i++) {
        level2 = level1[i].split('=');
        requestObj[level2[0]] = level2[1];
    }
    return requestObj[value];
}

Initial URL

                                

Initial Description

                                

Initial Title
request url variables with javascript

Initial Tags
url, javascript

Initial Language
JavaScript