Tuesday, May 15, 2012

Get the Querystring variables using javascript


This JS block helps you to get the query string values of a url at the client side.


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;
        }

If you want to get the query string value of “RecordId” simply you can say
var recordIdValue = getUrlVars()["RecordId"];

The record id will contain the RecordId value

No comments:

Post a Comment