I use "_spPageContextInfo.webAbsoluteUrl
" to detect the site url.
- From root site:
_spPageContextInfo.webAbsoluteUrl
, the result is "http://mywebsite:8888" - From subsite level 1:
_spPageContextInfo.webAbsoluteUrl
, the result is "http://mywebsite:8888/subsite1" - From subsite level 2:
_spPageContextInfo.webAbsoluteUrl
, the result is "http://mywebsite:8888/subsite1/subsite1_1"
How to identity your current site which you are surfing is root site or subsite by javascript? If subsite, which level of subsite is it? The solution is only javascript and only bases on the site url.
Thanks for helping.