_spBodyOnLoadFunctionNames.push("FetchURL");
function FetchURL()
{
// Custom JavaScript methods
var ctx = new SP.ClientContext();
var site = ctx.get_site();
ctx.load(site);
ctx.executeQueryAsync(function(s, a){ currURL=SP.Utilities.Utility.getLayoutsPageUrl("");
});
}
The above method returns the URL, however, sometimes it returns undefined, which causes errors. How to tackle this?
Code is placed in head of the masterpage... in scripts tag.