0

I'm trying to figure out how to get the site collection url for any version of SharePoint, not sure which method would be the best

I figure using window.location probably isn't reliable, clientContext I don't think is available in 2007, SPServices i'm not sure I need to make a web call for just this and that seems excessive.

Any thoughts?

1 Answer 1

-1

It will work using window.location.

Try with this:

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

For Example: URL: http://yourdomain/sites/hr/pages/default.aspx _spPageContextInfo.siteServerRelativeUrl returns: /sites/hr

1
  • pagecontextinfo isn't available in 2007 also siteServerRelativeUrl doesn't work if I'm inside a subsite.
    – Batman
    May 26, 2016 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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