Can anyone provide a sample code for getting HostWebUrl and AppWebUrl when redirect from Default page to another page. How can we do this ? I am using the following code its work for Default but not for another page-
hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
var scriptbase = hostweburl + "/_layouts/15/";
var context = new SP.ClientContext(appweburl);
appContextSite = new SP.AppContextSite(context, hostweburl);
web = appContextSite.get_web();