SPGetCurrentSite
Function
$().SPServices.SPGetCurrentSite
Certification
Functionality
This utility function, which is also publicly available, simply returns the current site’s URL. It mirrors the functionality of the WebUrlFromPageUrl operation.
Note: There is a bug in the versions 2013.01, 2013.02, and 2014.01 where only the relative path (
"/"
) is returned rather than the full path ("http://servername/sitename"
). This causes problems in the root site for $().SPServices.SPGetCurrentSite and $().SPServices.SPGetCurrentUser.Syntax
$().SPServices.SPGetCurrentSite();
Example
var thisSite = $().SPServices.SPGetCurrentSite();
Available Options
None
Returns
The current site URL as a string. For example, if the current page is:
http://servername/sitename/Pages/default.aspx
orhttp://servername/sitename/Shared%20Documents/Forms/EditForm.aspx
orhttp://servername/sitename/Lists/Calendar/NewForm.aspx
the function will return:
http://servername/sitename