You can use the following code snippet:
Uri myurl = new Uri(Request.QueryString["SPHostUrl"]); string param1 = HttpUtility.ParseQueryString(myUri.Query).Get("p");
or use
string param1 = Request.QueryString["p"];
If you want this via JS, then continue with this.
function getQueryStringParameter(paramToRetrieve) { var params; var strParams; params = document.URL.split("?")[1].split("&"); strParams = ""; for (var i = 0; i < params.length; i = i + 1) { var singleParam = params[i].split("="); if (singleParam[0] == paramToRetrieve) return singleParam[1]; } } var sProp = decodeURIComponent(getQueryStringParameter("StringProperty1")); document.write('Value of StringProperty1 : ' + sProp + '</br>');
source share