2

I've created an application where the user has to enter a site URL (plus credentials etc). I want to explain how to get from an URL in the browser's address bar to the site URL, e.g. from:

https://myCompany.sharepoint.com/sites/mySite/SitePages/Home.aspx

to:

https://myCompany.sharepoint.com/sites/mySite/

Experienced users will derive the rule by common sense but for the uninitiated this may be a challenge. Is there a general rules that one can use as guidance?

  • not sure what/why you would want something like this, but why dont you simply remove everything yourself that appears after /sitepages or /pages or /list1/forms/... – Tiago Duarte Feb 22 '17 at 21:13
  • You could write some custom javascript code using the _spPageContextInfo object to pull the web absolute url out of the url, which should be what you're looking for if I understand your issue correctly. – David Hartman Feb 23 '17 at 3:19
2

If You are using Client Side, then you can use

_spPageContextInfo.webAbsoluteUrl or _spPageContextInfo.siteAbsoluteUrl

to fetch the web absolute url.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.