Url Parsing In Jquery

Get Url(domain) parameter using jquery function.
In below code, I wrote one function called getUrlVars().
Using this function you can get requesting parameter value.
If parameter not found., It will return undefined response
It was working for me good.

    
    var ID= getUrlVars()["id"];
    if(ID==undefined){
        ID='';
    }
    function getUrlVars() {
        var vars = {};
        var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
                     function(m,key,value) {
                       vars[key] = value;
                     });
        return vars;
    }

OUTPUT

    
Url:http://mydomain.com/index.php?id=1
In js:    var ID= getUrlVars()["id"];
Output
ID=1
In js:    var ID= getUrlVars()["name"];
Output:
ID=undefined