title: Sharepoint How to identify your current site is rootsite or subsite (level of subsite)?
body: <p>I use "<code>_spPageContextInfo.webAbsoluteUrl</code>" to detect the site url.</p>
  
  <ul>
  <li>From root site: <code>_spPageContextInfo.webAbsoluteUrl</code>, the result is "<a href="http://mywebsite:8888" rel="nofollow noreferrer">http://mywebsite:8888</a>"</li>
  <li>From subsite level 1: <code>_spPageContextInfo.webAbsoluteUrl</code>, the result is "<a href="http://mywebsite:8888/subsite1" rel="nofollow noreferrer">http://mywebsite:8888/subsite1</a>"</li>
  <li>From subsite level 2: <code>_spPageContextInfo.webAbsoluteUrl</code>, the result is "<a href="http://mywebsite:8888/subsite1/subsite1_1" rel="nofollow noreferrer">http://mywebsite:8888/subsite1/subsite1_1</a>"</li>
  </ul>
  
  <p>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.</p>
  
  <p>Thanks for helping.</p>