Last Updated: February 25, 2016
·
615
· arthur-alves

Very simple JS request all url vars

Very simple request all vars from url. Easy to understand.

function requestUrlVars(){ 
    var params = window.location.search
    if (params){
        var url_params = params.replace('?','').split('&');
        var requests = {};
        for(var i in url_params){
            var key = url_params[i].split('=');
            requests[key[0]] =  key[1];
        }
        return requests;    
    }else{
        return false;
    };
};

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside