Read querystring value using javascript

By
Advertisement
Introduction:

In my previous article I have explained about uploadingfile to ftp server using C#.Net. In this article I am going to explain about how to get querystring value in javascript.

Explanation:
Below is the javascript function to read querystring values

function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

To call this function
var location1 = getUrlVars()["lat1"];

0 comments:

Post a Comment

Online Casino