Skip to main content

You can do it without any SharePoint calls by using the default JavaScript location object (W3schools) and the page variable _spPageContextInfo_spPageContextInfo (Ted Pattison's Blog).

Something like:

var url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;

var url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;

You can do it without any SharePoint calls by using the default JavaScript location object (W3schools) and the page variable _spPageContextInfo (Ted Pattison's Blog)

Something like:

var url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;

You can do it without any SharePoint calls by using the default JavaScript location object (W3schools) and the page variable _spPageContextInfo (Ted Pattison's Blog).

Something like:

var url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;
Source Link

You can do it without any SharePoint calls by using the default JavaScript location object (W3schools) and the page variable _spPageContextInfo (Ted Pattison's Blog)

Something like:

var url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;