Get Url Parameter in JQuery
// Assuming url "http://www.abc.com?cd=1234&name=ram kumar"
<script>
function getUrlParameter(param_name) {
param_name = param_name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + param_name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
$(document).ready(function () {
alert(getUrlParameter("cd"));
var v_cd = getUrlParameter("cd");
var v_name = getUrlParameter("name");
});
</script>
Result
123
ram kumar
No comments:
Post a Comment