i will get SharePoint Tenent Site URl using Javascript...
below My Site URL:- https://pp1.sharepoint.com/sites/Test/Poject/
I have get only Tenent Site URL:-
i will get SharePoint Tenent Site URl using Javascript...
below My Site URL:- https://pp1.sharepoint.com/sites/Test/Poject/
I have get only Tenent Site URL:-
You can use the below code:
var tenantUri = window.location.protocol + "//" + window.location.host;
//you can replace window.location.protocol with https: as in case of SPO it will always be https
console.log(tenantUri)
This will give you the tenant url irrespective of your path.
code to get root site collection url:
string rootSiteCollectionURL = SPContext.Current.Web.Site.WebApplication.Sites[0].Url;
// site collection url
string SiteCollectionURL = SPContext.Current.Web.Site.Url;
Using JavaScript:
window.location.origin