Posted in Code Snippets, Javascript

Get query string value

Get the value of a field from query string using JavaScript:

function getURLParameter(name) {
    return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)
                              (&|#|;|$)').exec(location.search)||[,""])
                              [1].replace(/\+/g, '%20'))||null
}

Continue reading “Get query string value”

Advertisements