In this post we will be writing a function to retrieve the query string value by passing the parameters siteUrl and querystringkey using Javascript.
function getQuerystringForUrl(key,siteUrl) {
key = decodeURIComponent(key).replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + key + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(siteUrl);
if (results == null)
return;
else
return decodeURIComponent(results[1]);
}
No comments:
Post a Comment